Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2023-10-28 10:17:38
Exec Total Coverage
Lines: 1667 4284 38.9%
Functions: 130 332 39.2%
Branches: 925 2930 31.6%

Line Branch Exec Source
1 #include "zc/zc_sys.h"
2
3 #include "allegro/gfx.h"
4 #include "allegro5/joystick.h"
5 #include "base/qrs.h"
6 #include "base/dmap.h"
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <cstring>
10 #include <math.h>
11 #include <map>
12 #include <filesystem>
13 #include <ctype.h>
14 #include <sstream>
15 #include "base/zc_alleg.h"
16 #include "gamedata.h"
17 #include "zc/zc_init.h"
18 #include "init.h"
19 #include "zc/replay.h"
20 #include "zc/cheats.h"
21 #include "zc/render.h"
22 #include "base/zc_math.h"
23 #include "base/zapp.h"
24 #include "dialog/cheatkeys.h"
25 #include "metadata/metadata.h"
26 #include "zc/zelda.h"
27 #include "zc/saves.h"
28 #include "tiles.h"
29 #include "base/colors.h"
30 #include "pal.h"
31 #include "base/zsys.h"
32 #include "qst.h"
33 #include "zc/zc_sys.h"
34 #include "play_midi.h"
35 #include "gui/jwin_a5.h"
36 #include "base/jwinfsel.h"
37 #include "base/gui.h"
38 #include "midi.h"
39 #include "subscr.h"
40 #include "zc/maps.h"
41 #include "sprite.h"
42 #include "zc/guys.h"
43 #include "zc/hero.h"
44 #include "zc/title.h"
45 #include "particles.h"
46 #include "sound/zcmusic.h"
47 #include "zconsole.h"
48 #include "zc/ffscript.h"
49 #include "dialog/info.h"
50 #include "dialog/alert.h"
51 #include "zc/combos.h"
52 #include "zc/jit.h"
53 #include "zc/zc_subscr.h"
54 #include <fmt/format.h>
55 #include "zinfo.h"
56 #include "base/misctypes.h"
57
58 #ifdef __EMSCRIPTEN__
59 #include "base/emscripten_utils.h"
60 #endif
61
62 using namespace std::chrono_literals;
63
64 extern FFScript FFCore;
65 extern bool Playing;
66 int32_t sfx_voice[WAV_COUNT];
67 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
68 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
69
70 static ALLEGRO_JOYSTICK* gamepad_dlg_cur_joystick;
71 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c);
72
73 extern byte monochrome_console;
74
75 extern HeroClass Hero;
76 extern zcmodule moduledata;
77 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
78 extern particle_list particles;
79 extern int32_t loadlast;
80 extern char *sfx_string[WAV_COUNT];
81 byte use_dwm_flush;
82 byte use_save_indicator;
83 int32_t paused_midi_pos = 0;
84 byte midi_suspended = 0;
85 byte zc_192b163_warp_compatibility;
86 char modulepath[2048];
87 bool epilepsyFlashReduction;
88 signed char pause_in_background_menu_init = 0;
89 byte pause_in_background = 0;
90 bool is_sys_pal = false;
91 static bool load_control_called_this_frame;
92 extern PALETTE* hw_palette;
93 extern bool update_hw_pal;
94 extern const char* dmaplist(int32_t index, int32_t* list_size);
95 int32_t getnumber(const char *prompt,int32_t initialval);
96
97 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
98 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
99
100 static const char *qst_module_name = "current_module";
101 #ifdef ALLEGRO_LINUX
102 static const char *samplepath = "samplesoundset/patches.dat";
103 #endif
104 char qst_files_path[2048];
105
106 #ifdef _MSC_VER
107 #define getcwd _getcwd
108 #endif
109
110 bool rF11();
111 bool rI();
112 bool rQ();
113 bool zc_key_pressed();
114
115 #ifdef _WIN32
116
117 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
118 extern "C"
119 {
120 typedef HRESULT(WINAPI *t_DwmFlush)();
121 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
122 }
123
124 void do_DwmFlush()
125 {
126 static HMODULE shell = LoadLibrary("dwmapi.dll");
127
128 if(!shell)
129 return;
130
131 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
132 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
133
134 BOOL enabled;
135 isEnabled(&enabled);
136
137 if(isEnabled)
138 flush();
139 }
140
141 #endif // _WIN32
142
143 83751 bool flash_reduction_enabled(bool check_qr)
144 {
145
4/4
✓ Branch 0 taken 81530 times.
✓ Branch 1 taken 2221 times.
✓ Branch 2 taken 81074 times.
✓ Branch 3 taken 83295 times.
83751 return (check_qr && get_qr(qr_EPILEPSY)) || epilepsyFlashReduction || replay_is_debug();
146 }
147
148 // Dialogue largening
149 void large_dialog(DIALOG *d)
150 {
151 large_dialog(d, 1.5);
152 }
153
154 void large_dialog(DIALOG *d, float RESIZE_AMT)
155 {
156 if(!d[0].d1)
157 {
158 d[0].d1 = 1;
159 int32_t oldwidth = d[0].w;
160 int32_t oldheight = d[0].h;
161 int32_t oldx = d[0].x;
162 int32_t oldy = d[0].y;
163 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
164 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
165 d[0].w = int32_t(d[0].w*RESIZE_AMT);
166 d[0].h = int32_t(d[0].h*RESIZE_AMT);
167
168 for(int32_t i=1; d[i].proc !=NULL; i++)
169 {
170 // Place elements horizontally
171 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
172 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
173
174 if(d[i].proc != d_stringloader)
175 {
176 if(d[i].proc==d_bitmap_proc)
177 {
178 d[i].w *= 2;
179 }
180 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
181 }
182
183 // Place elements vertically
184 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
185 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
186
187 // Vertically resize elements
188 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
189 {
190 d[i].h = int32_t((double)d[i].h*1.5);
191 }
192 else if(d[i].proc == jwin_droplist_proc || d[i].proc == d_joylist_proc)
193 {
194 d[i].y += int32_t((double)d[i].h*0.25);
195 d[i].h = int32_t((double)d[i].h*1.25);
196 }
197 else if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].h *= 2;
200 }
201 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
202
203 // Fix frames
204 if(d[i].proc == jwin_frame_proc)
205 {
206 d[i].x++;
207 d[i].y++;
208 d[i].w-=4;
209 d[i].h-=4;
210 }
211 }
212 }
213
214 for(int32_t i=1; d[i].proc!=NULL; i++)
215 {
216 if(d[i].proc==jwin_slider_proc)
217 continue;
218
219 // Bigger font
220 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc && d[i].proc != d_joylist_proc);
221
222 if(!d[i].dp2 && bigfontproc)
223 {
224 d[i].dp2 = get_zc_font(font_lfont_l);
225 }
226 else if(!bigfontproc)
227 {
228 ((ListData *)d[i].dp)->font = &a4fonts[font_lfont_l];
229 }
230
231 // Make checkboxes work
232 if(d[i].proc == jwin_check_proc)
233 d[i].proc = jwin_checkfont_proc;
234 else if(d[i].proc == jwin_radio_proc)
235 d[i].proc = jwin_radiofont_proc;
236 }
237
238 jwin_center_dialog(d);
239 }
240
241
242 /**********************************/
243 /******** System functions ********/
244 /**********************************/
245
246 static char cfg_sect[] = "zeldadx"; //We need to rename this.
247 static char ctrl_sect[] = "Controls";
248 static char sfx_sect[] = "Volume";
249
250 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
251 {
252 return D_O_K;
253 }
254
255 bool is_reserved_key(int c)
256 {
257 switch(c)
258 {
259 case KEY_ESC:
260 return true;
261 }
262 return false;
263 }
264 bool is_reserved_keycombo(int c, int modflag)
265 {
266 if(c==KEY_F4 && (modflag&KB_ALT_FLAG))
267 return true;
268 return false;
269 }
270 bool checkcheat(Cheat cheat)
271 {
272 if(cheatkeys[cheat][0] && zc_readkey(cheatkeys[cheat][0]))
273 return true; //Main key pressed
274 if(cheatkeys[cheat][1] && zc_readkey(cheatkeys[cheat][1]))
275 return true; //Alt key pressed
276 return false;
277 }
278 114 void load_default_cheatkeys()
279 {
280 114 memset(cheatkeys, 0, sizeof(cheatkeys));
281 114 cheatkeys[Cheat::Life][0] = KEY_H;
282 114 cheatkeys[Cheat::Life][1] = KEY_ASTERISK;
283 114 cheatkeys[Cheat::Magic][0] = KEY_M;
284 114 cheatkeys[Cheat::Magic][1] = KEY_SLASH_PAD;
285 114 cheatkeys[Cheat::Rupies][0] = KEY_R;
286 114 cheatkeys[Cheat::Bombs][0] = KEY_B;
287 114 cheatkeys[Cheat::Arrows][0] = KEY_A;
288 114 cheatkeys[Cheat::Clock][0] = KEY_I;
289 114 cheatkeys[Cheat::Walls][0] = KEY_F11;
290 114 cheatkeys[Cheat::Fast][0] = KEY_Q;
291 114 cheatkeys[Cheat::Light][0] = KEY_L;
292 114 cheatkeys[Cheat::IgnoreSideView][0] = KEY_V;
293 114 cheatkeys[Cheat::Kill][0] = KEY_K;
294 114 cheatkeys[Cheat::GoTo][0] = KEY_G;
295 114 cheatkeys[Cheat::TrigSecrets][0] = KEY_S;
296 114 cheatkeys[Cheat::ShowL0][0] = KEY_0;
297 114 cheatkeys[Cheat::ShowL1][0] = KEY_1;
298 114 cheatkeys[Cheat::ShowL2][0] = KEY_2;
299 114 cheatkeys[Cheat::ShowL3][0] = KEY_3;
300 114 cheatkeys[Cheat::ShowL4][0] = KEY_4;
301 114 cheatkeys[Cheat::ShowL5][0] = KEY_5;
302 114 cheatkeys[Cheat::ShowL6][0] = KEY_6;
303 114 cheatkeys[Cheat::ShowFFC][0] = KEY_7;
304 114 cheatkeys[Cheat::ShowSprites][0] = KEY_8;
305 114 cheatkeys[Cheat::ShowWalkability][0] = KEY_W;
306 114 cheatkeys[Cheat::ShowEffects][0] = KEY_E;
307 114 cheatkeys[Cheat::ShowOverhead][0] = KEY_O;
308 114 cheatkeys[Cheat::ShowPushblock][0] = KEY_P;
309 114 cheatkeys[Cheat::ShowHitbox][0] = KEY_C;
310 114 cheatkeys[Cheat::ShowFFCScripts][0] = KEY_F;
311 114 }
312 114 void load_game_configs()
313 {
314 114 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
315 114 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
316 114 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
317 114 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
318 114 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
319 114 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
320 114 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
321 114 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
322 114 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
323 114 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
324 114 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
325 114 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
326 114 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
327 114 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
328 114 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
329
330 //cheat modifier keya
331 114 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
332 114 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
333 114 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
334 114 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
335
336 //cheat keys
337 114 load_default_cheatkeys();
338 char buf[256];
339
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 3990 times.
4104 for(size_t q = 1; q < Cheat::Last; ++q)
340 {
341
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 if(!bindable_cheat((Cheat)q)) continue;
342 3990 std::string cheatname = cheat_to_string((Cheat)q);
343
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 util::lowerstr(cheatname);
344 3990 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
345
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 cheatkeys[q][0] = zc_get_config(ctrl_sect,buf,cheatkeys[q][0]);
346 3990 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
347
1/2
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
3990 cheatkeys[q][1] = zc_get_config(ctrl_sect,buf,cheatkeys[q][1]);
348 3990 }
349
350
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
351 joystick_index = 0;
352
353 114 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
354 114 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
355 114 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
356 114 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
357 114 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
358 114 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
359 114 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
360 114 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
361 114 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
362 114 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
363
364 114 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
365 114 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
366 114 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
367 114 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
368
369 114 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
370 114 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
371 114 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
372 114 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
373 114 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
374 114 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
375 114 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
376 114 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
377 114 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
378 114 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
379 114 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
380
381 114 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
382 114 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
383 114 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
384 114 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
385
386 114 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
387
388 114 digi_volume = zc_get_config(sfx_sect,"digi",248);
389 114 midi_volume = zc_get_config(sfx_sect,"midi",255);
390 114 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
391 114 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
392 114 pan_style = zc_get_config(sfx_sect,"pan",1);
393 // 1 <= zcmusic_bufsz <= 128
394 114 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
395 114 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
396 114 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
397 114 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
398 114 Maxfps = zc_get_config(cfg_sect,"maxfps",0);
399 114 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
400 114 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
401 114 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
402 #ifdef __EMSCRIPTEN__
403 if (em_is_mobile()) NameEntryMode = 2;
404 #endif
405 114 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
406 114 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
407 114 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
408 114 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
409 114 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
410
411 //default - scale x2, 640 x 480
412 114 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
413 114 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
414 114 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
415 114 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
416 114 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
417 114 scaleForceInteger = zc_get_config("zeldadx","scaling_force_integer",1)!=0;
418 114 stretchGame = zc_get_config("zeldadx","stretch_game_area",0)!=0;
419
420 114 loadlast = zc_get_config(cfg_sect,"load_last",0);
421
422 114 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
423
424 114 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
425
426 114 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
427 114 info_opacity = zc_get_config("zc","debug_info_opacity",255);
428 #ifdef _WIN32
429 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
430 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
431 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
432 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
433
434 // This one's for Aero
435 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
436
437 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
438 #else //UNIX
439 114 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
440 114 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
441 114 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
442 #endif
443 114 clearConsoleOnLoad = zc_get_config("CONSOLE","clear_console_on_load",1)!=0;
444 114 clearConsoleOnReload = zc_get_config("CONSOLE","clear_console_on_reload",0)!=0;
445
446 114 strcpy(qstdir,zc_get_config(cfg_sect,"quest_dir","quests"));
447 114 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
448 114 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
449 114 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
450 114 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
451 114 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
452 114 heart_beep = zc_get_config(cfg_sect,"heart_beep",0)!=0;
453 //gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
454 114 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
455 114 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
456 114 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
457 114 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
458 114 }
459
460 void save_control_configs(bool kb)
461 {
462 if(kb)
463 {
464 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
465 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
466 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
467 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
468
469 if (!replay_is_replaying())
470 {
471 zc_set_config(ctrl_sect,"key_a",Akey);
472 zc_set_config(ctrl_sect,"key_b",Bkey);
473 zc_set_config(ctrl_sect,"key_s",Skey);
474 zc_set_config(ctrl_sect,"key_l",Lkey);
475 zc_set_config(ctrl_sect,"key_r",Rkey);
476 zc_set_config(ctrl_sect,"key_p",Pkey);
477 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
478 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
479 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
480 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
481 zc_set_config(ctrl_sect,"key_up", DUkey);
482 zc_set_config(ctrl_sect,"key_down", DDkey);
483 zc_set_config(ctrl_sect,"key_left", DLkey);
484 zc_set_config(ctrl_sect,"key_right",DRkey);
485 }
486 }
487 else
488 {
489 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
490 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
491 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
492 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
493 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
494 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
495 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
496 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
497 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
498 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
499 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
500 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
501 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
502 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
503
504 zc_set_config(ctrl_sect,"btn_a",Abtn);
505 zc_set_config(ctrl_sect,"btn_b",Bbtn);
506 zc_set_config(ctrl_sect,"btn_s",Sbtn);
507 zc_set_config(ctrl_sect,"btn_m",Mbtn);
508 zc_set_config(ctrl_sect,"btn_l",Lbtn);
509 zc_set_config(ctrl_sect,"btn_r",Rbtn);
510 zc_set_config(ctrl_sect,"btn_p",Pbtn);
511 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
512 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
513 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
514 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
515
516 zc_set_config(ctrl_sect,"btn_up",DUbtn);
517 zc_set_config(ctrl_sect,"btn_down",DDbtn);
518 zc_set_config(ctrl_sect,"btn_left",DLbtn);
519 zc_set_config(ctrl_sect,"btn_right",DRbtn);
520 }
521 }
522
523 void save_cheatkeys()
524 {
525 char buf[256];
526 for(size_t q = 1; q < Cheat::Last; ++q)
527 {
528 if(!bindable_cheat((Cheat)q)) continue;
529 std::string cheatname = cheat_to_string((Cheat)q);
530 util::lowerstr(cheatname);
531 sprintf(buf, "key_cheat_%s_main", cheatname.c_str());
532 zc_set_config(ctrl_sect,buf,cheatkeys[q][0]);
533 sprintf(buf, "key_cheat_%s_alt", cheatname.c_str());
534 if(cheatkeys[q][1])
535 zc_set_config(ctrl_sect,buf,cheatkeys[q][1]);
536 else zc_set_config(ctrl_sect,buf,(char*)nullptr);
537 }
538 }
539
540 void save_game_configs()
541 {
542 packfile_password("");
543
544 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
545
546 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
547 {
548 int o_window_x, o_window_y;
549 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
550 zc_set_config(cfg_sect,"window_x",o_window_x);
551 zc_set_config(cfg_sect,"window_y",o_window_y);
552 }
553
554 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
555 {
556 double monitor_scale = zc_get_monitor_scale();
557 window_width = al_get_display_width(all_get_display()) / monitor_scale;
558 window_height = al_get_display_height(all_get_display()) / monitor_scale;
559 zc_set_config(cfg_sect,"window_width",window_width);
560 zc_set_config(cfg_sect,"window_height",window_height);
561 }
562
563 zc_set_config(cfg_sect,"load_last",loadlast);
564 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
565
566 flush_config_file();
567 #ifdef __EMSCRIPTEN__
568 em_sync_fs();
569 #endif
570 }
571
572 //----------------------------------------------------------------
573
574 // Timers
575
576 32083 void fps_callback()
577 {
578 32083 lastfps=framecnt;
579 32083 framecnt=0;
580 32083 }
581
582 END_OF_FUNCTION(fps_callback)
583
584 114 int32_t Z_init_timers()
585 {
586 static bool didit = false;
587 const static char *err_str = "Couldn't allocate timer";
588 114 err_str = err_str; //Unused variable warning
589
590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(didit)
591 return 1;
592
593 114 didit = true;
594
595 LOCK_VARIABLE(lastfps);
596 LOCK_VARIABLE(framecnt);
597 LOCK_FUNCTION(fps_callback);
598
599
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
600 return 0;
601
602 114 return 1;
603 114 }
604
605 void Z_remove_timers()
606 {
607 remove_int(fps_callback);
608 }
609
610 //----------------------------------------------------------------
611
612 void go()
613 {
614 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
615 }
616
617 void comeback()
618 {
619 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
620 }
621
622 void dump_pal(BITMAP *dest)
623 {
624 for(int32_t i=0; i<256; i++)
625 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
626 }
627
628 //----------------------------------------------------------------
629
630 int game_mouse_index = ZCM_BLANK;
631 static bool system_mouse = false;
632 28 bool sys_mouse()
633 {
634 28 system_mouse = true;
635 28 return MouseSprite::set(ZCM_NORMAL);
636 }
637 555 bool game_mouse()
638 {
639 555 system_mouse = false;
640 555 return MouseSprite::set(game_mouse_index);
641 }
642 void custom_mouse(BITMAP* bmp, int fx, int fy, bool sys_recolor, bool user_scale)
643 {
644 if(!bmp)
645 return;
646 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
647 int scaledw = bmp->w*scale, scaledh = bmp->h*scale;
648 if(bmp->w == scaledw && bmp->h == scaledh)
649 user_scale = false;
650 if(user_scale || sys_recolor)
651 {
652 if(!user_scale) scale = 1;
653 BITMAP* tmpbmp = create_bitmap_ex(8,bmp->w*scale,bmp->h*scale);
654 if(user_scale)
655 stretch_blit(bmp, tmpbmp, 0, 0, bmp->w, bmp->h, 0, 0, tmpbmp->w, tmpbmp->h);
656 else
657 blit(bmp, tmpbmp, 0, 0, 0, 0, bmp->w, bmp->h);
658 if(sys_recolor)
659 recolor_mouse(tmpbmp);
660 MouseSprite::assign(ZCM_CUSTOM, tmpbmp, fx*scale, fy*scale);
661 destroy_bitmap(tmpbmp);
662 }
663 else
664 {
665 MouseSprite::assign(ZCM_CUSTOM, bmp, fx, fy);
666 }
667 }
668
669 //Handles converting the mouse sprite from the .dat file
670 void recolor_mouse(BITMAP* bmp)
671 {
672 for(int32_t x = 0; x < bmp->w; ++x)
673 {
674 for(int32_t y = 0; y < bmp->h; ++y)
675 {
676 int32_t color = getpixel(bmp, x, y);
677 switch(color)
678 {
679 case dvc(1):
680 color = jwin_pal[jcCURSORMISC];
681 break;
682 case dvc(2):
683 color = jwin_pal[jcCURSOROUTLINE];
684 break;
685 case dvc(3):
686 color = jwin_pal[jcCURSORLIGHT];
687 break;
688 case dvc(5):
689 color = jwin_pal[jcCURSORDARK];
690 break;
691 default:
692 continue;
693 }
694 putpixel(bmp, x, y, color);
695 }
696 }
697 }
698 void load_mouse()
699 {
700 PALETTE pal;
701 BITMAP* cursor_bitmap = load_bitmap("assets/cursor.bmp", pal);
702 if (!cursor_bitmap)
703 Z_error_fatal("Missing required file %s\n", "assets/cursor.bmp");
704
705 enter_sys_pal();
706 MouseSprite::set(-1);
707 float scale = vbound(zc_get_config("zeldadx","cursor_scale_large",1.5),1.0,5.0);
708 int32_t sz = 16*scale;
709 for(int32_t j = 0; j < 1; ++j)
710 {
711 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
712 if(zcmouse[j])
713 destroy_bitmap(zcmouse[j]);
714 zcmouse[j] = create_bitmap_ex(8,sz,sz);
715 clear_bitmap(zcmouse[j]);
716 clear_bitmap(tmpbmp);
717 blit(cursor_bitmap,tmpbmp,1,j*17+1,0,0,16,16);
718 recolor_mouse(tmpbmp);
719 if(sz!=16)
720 stretch_blit(tmpbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
721 else
722 blit(tmpbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
723 destroy_bitmap(tmpbmp);
724 }
725 if(!hw_palette) hw_palette = &RAMpal;
726 zc_set_palette(*hw_palette);
727
728 BITMAP* blankmouse = create_bitmap_ex(8,16,16);
729 clear_bitmap(blankmouse);
730
731 MouseSprite::assign(ZCM_NORMAL, zcmouse[0], 1*scale, 1*scale);
732 MouseSprite::assign(ZCM_BLANK, blankmouse);
733 //Don't assign ZCM_CUSTOM. That'll be handled by scripts.
734
735 //Reload the mouse
736 if(system_mouse)
737 sys_mouse();
738 else game_mouse();
739
740 destroy_bitmap(blankmouse);
741 destroy_bitmap(cursor_bitmap);
742 exit_sys_pal();
743 }
744
745 // sets the video mode and initializes the palette and mouse sprite
746 114 bool game_vid_mode(int32_t mode,int32_t wait)
747 {
748
1/2
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
114 if (is_headless())
749 114 return true;
750
751 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
752 {
753 return false;
754 }
755
756 scrx = (resx-320)>>1;
757 scry = (resy-240)>>1;
758 for(int32_t q = 0; q < NUM_ZCMOUSE; ++q)
759 zcmouse[q] = NULL;
760 load_mouse();
761
762 for(int32_t i=240; i<256; i++)
763 RAMpal[i]=pal_gui[i];
764
765 zc_set_palette(RAMpal);
766 clear_to_color(screen,BLACK);
767
768 rest(wait);
769 return true;
770 114 }
771
772 8 void null_quest()
773 {
774 char qstdat_string[2048];
775 8 strcpy(qstdat_string, "modules/classic/default.qst");
776
777 #ifdef __EMSCRIPTEN__
778 // The quest template data file is not included because it's really big and isn't really needed
779 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
780 // which is much smaller.
781 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
782 #endif
783
784 8 byte skip_flags[4] = { 0 };
785
786 8 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,skip_flags,0,false);
787 8 }
788
789 8 void init_NES_mode()
790 {
791 8 null_quest();
792 8 }
793
794 //----------------------------------------------------------------
795
796 qword trianglelines[16]=
797 {
798 0x0000000000000000ULL,
799 0xFD00000000000000ULL,
800 0xFDFD000000000000ULL,
801 0xFDFDFD0000000000ULL,
802 0xFDFDFDFD00000000ULL,
803 0xFDFDFDFDFD000000ULL,
804 0xFDFDFDFDFDFD0000ULL,
805 0xFDFDFDFDFDFDFD00ULL,
806 0xFDFDFDFDFDFDFDFDULL,
807 0x00FDFDFDFDFDFDFDULL,
808 0x0000FDFDFDFDFDFDULL,
809 0x000000FDFDFDFDFDULL,
810 0x00000000FDFDFDFDULL,
811 0x0000000000FDFDFDULL,
812 0x000000000000FDFDULL,
813 0x00000000000000FDULL,
814 };
815
816 word screen_triangles[28][32];
817 /*
818 qword triangles[4][16]= //[direction][value]
819 {
820 {
821 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
822 },
823 {
824 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
825 },
826 {
827 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
828 },
829 {
830 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
831 }
832 };
833 */
834
835
836 /*
837 byte triangles[4][16][8]= //[direction][value][line]
838 {
839 {
840 {
841 0, 0, 0, 0, 0, 0, 0, 0
842 },
843 {
844 1, 0, 0, 0, 0, 0, 0, 0
845 },
846 {
847 2, 1, 0, 0, 0, 0, 0, 0
848 },
849 {
850 3, 2, 1, 0, 0, 0, 0, 0
851 },
852 {
853 4, 3, 2, 1, 0, 0, 0, 0
854 },
855 {
856 5, 4, 3, 2, 1, 0, 0, 0
857 },
858 {
859 6, 5, 4, 3, 2, 1, 0, 0
860 },
861 {
862 7, 6, 5, 4, 3, 2, 1, 0
863 },
864 {
865 8, 7, 6, 5, 4, 3, 2, 1
866 },
867 {
868 8, 8, 7, 6, 5, 4, 3, 2
869 },
870 {
871 8, 8, 8, 7, 6, 5, 4, 3
872 },
873 {
874 8, 8, 8, 8, 7, 6, 5, 4
875 },
876 {
877 8, 8, 8, 8, 8, 7, 6, 5
878 },
879 {
880 8, 8, 8, 8, 8, 8, 7, 6
881 },
882 {
883 8, 8, 8, 8, 8, 8, 8, 7
884 },
885 {
886 8, 8, 8, 8, 8, 8, 8, 8
887 }
888 },
889 {
890 {
891 0, 0, 0, 0, 0, 0, 0, 0
892 },
893 {
894 15, 0, 0, 0, 0, 0, 0, 0
895 },
896 {
897 14, 15, 0, 0, 0, 0, 0, 0
898 },
899 {
900 13, 14, 15, 0, 0, 0, 0, 0
901 },
902 {
903 12, 13, 14, 15, 0, 0, 0, 0
904 },
905 {
906 11, 12, 13, 14, 15, 0, 0, 0
907 },
908 {
909 10, 11, 12, 13, 14, 15, 0, 0
910 },
911 {
912 9, 10, 11, 12, 13, 14, 15, 0
913 },
914 {
915 8, 9, 10, 11, 12, 13, 14, 15
916 },
917 {
918 8, 8, 9, 10, 11, 12, 13, 14
919 },
920 {
921 8, 8, 8, 9, 10, 11, 12, 13
922 },
923 {
924 8, 8, 8, 8, 9, 10, 11, 12
925 },
926 {
927 8, 8, 8, 8, 8, 9, 10, 11
928 },
929 {
930 8, 8, 8, 8, 8, 8, 9, 10
931 },
932 {
933 8, 8, 8, 8, 8, 8, 8, 9
934 },
935 {
936 8, 8, 8, 8, 8, 8, 8, 8
937 }
938 },
939 {
940 {
941 0, 0, 0, 0, 0, 0, 0, 0
942 },
943 {
944 0, 0, 0, 0, 0, 0, 0, 1
945 },
946 {
947 0, 0, 0, 0, 0, 0, 1, 2
948 },
949 {
950 0, 0, 0, 0, 0, 1, 2, 3
951 },
952 {
953 0, 0, 0, 0, 1, 2, 3, 4
954 },
955 {
956 0, 0, 0, 1, 2, 3, 4, 5
957 },
958 {
959 0, 0, 1, 2, 3, 4, 5, 6
960 },
961 {
962 0, 1, 2, 3, 4, 5, 6, 7
963 },
964 {
965 1, 2, 3, 4, 5, 6, 7, 8
966 },
967 {
968 2, 3, 4, 5, 6, 7, 8, 8
969 },
970 {
971 3, 4, 5, 6, 7, 8, 8, 8
972 },
973 {
974 4, 5, 6, 7, 8, 8, 8, 8
975 },
976 {
977 5, 6, 7, 8, 8, 8, 8, 8
978 },
979 {
980 6, 7, 8, 8, 8, 8, 8, 8
981 },
982 {
983 7, 8, 8, 8, 8, 8, 8, 8
984 },
985 {
986 8, 8, 8, 8, 8, 8, 8, 8
987 }
988 },
989 {
990 {
991 0, 0, 0, 0, 0, 0, 0, 0
992 },
993 {
994 0, 0, 0, 0, 0, 0, 0, 15
995 },
996 {
997 0, 0, 0, 0, 0, 0, 15, 14
998 },
999 {
1000 0, 0, 0, 0, 0, 15, 14, 13
1001 },
1002 {
1003 0, 0, 0, 0, 15, 14, 13, 12
1004 },
1005 {
1006 0, 0, 0, 15, 14, 13, 12, 11
1007 },
1008 {
1009 0, 0, 15, 14, 13, 12, 11, 10
1010 },
1011 {
1012 0, 15, 14, 13, 12, 11, 10, 9
1013 },
1014 {
1015 15, 14, 13, 12, 11, 10, 9, 8
1016 },
1017 {
1018 14, 13, 12, 11, 10, 9, 8, 8
1019 },
1020 {
1021 13, 12, 11, 10, 9, 8, 8, 8
1022 },
1023 {
1024 12, 11, 10, 9, 8, 8, 8, 8
1025 },
1026 {
1027 11, 10, 9, 8, 8, 8, 8, 8
1028 },
1029 {
1030 10, 9, 8, 8, 8, 8, 8, 8
1031 },
1032 {
1033 9, 8, 8, 8, 8, 8, 8, 8
1034 },
1035 {
1036 8, 8, 8, 8, 8, 8, 8, 8
1037 }
1038 }
1039 };
1040 */
1041
1042
1043
1044 /*
1045 for (int32_t blockrow=0; blockrow<30; ++i)
1046 {
1047 for (int32_t linerow=0; linerow<8; ++i)
1048 {
1049 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1050 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1051 {
1052 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1053 ++triangleline;
1054 }
1055 }
1056 }
1057 */
1058
1059 // the ULL suffixes are to prevent this warning:
1060 // warning: integer constant is too large for "int32_t" type
1061
1062 qword triangles[4][16][8]= //[direction][value][line]
1063 {
1064 {
1065 {
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL,
1071 0x0000000000000000ULL,
1072 0x0000000000000000ULL,
1073 0x0000000000000000ULL
1074 },
1075 {
1076 0xFD00000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL,
1081 0x0000000000000000ULL,
1082 0x0000000000000000ULL,
1083 0x0000000000000000ULL
1084 },
1085 {
1086 0xFDFD000000000000ULL,
1087 0xFD00000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL,
1091 0x0000000000000000ULL,
1092 0x0000000000000000ULL,
1093 0x0000000000000000ULL
1094 },
1095 {
1096 0xFDFDFD0000000000ULL,
1097 0xFDFD000000000000ULL,
1098 0xFD00000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL,
1101 0x0000000000000000ULL,
1102 0x0000000000000000ULL,
1103 0x0000000000000000ULL
1104 },
1105 {
1106 0xFDFDFDFD00000000ULL,
1107 0xFDFDFD0000000000ULL,
1108 0xFDFD000000000000ULL,
1109 0xFD00000000000000ULL,
1110 0x0000000000000000ULL,
1111 0x0000000000000000ULL,
1112 0x0000000000000000ULL,
1113 0x0000000000000000ULL
1114 },
1115 {
1116 0xFDFDFDFDFD000000ULL,
1117 0xFDFDFDFD00000000ULL,
1118 0xFDFDFD0000000000ULL,
1119 0xFDFD000000000000ULL,
1120 0xFD00000000000000ULL,
1121 0x0000000000000000ULL,
1122 0x0000000000000000ULL,
1123 0x0000000000000000ULL
1124 },
1125 {
1126 0xFDFDFDFDFDFD0000ULL,
1127 0xFDFDFDFDFD000000ULL,
1128 0xFDFDFDFD00000000ULL,
1129 0xFDFDFD0000000000ULL,
1130 0xFDFD000000000000ULL,
1131 0xFD00000000000000ULL,
1132 0x0000000000000000ULL,
1133 0x0000000000000000ULL
1134 },
1135 {
1136 0xFDFDFDFDFDFDFD00ULL,
1137 0xFDFDFDFDFDFD0000ULL,
1138 0xFDFDFDFDFD000000ULL,
1139 0xFDFDFDFD00000000ULL,
1140 0xFDFDFD0000000000ULL,
1141 0xFDFD000000000000ULL,
1142 0xFD00000000000000ULL,
1143 0x0000000000000000ULL
1144 },
1145 {
1146 0xFDFDFDFDFDFDFDFDULL,
1147 0xFDFDFDFDFDFDFD00ULL,
1148 0xFDFDFDFDFDFD0000ULL,
1149 0xFDFDFDFDFD000000ULL,
1150 0xFDFDFDFD00000000ULL,
1151 0xFDFDFD0000000000ULL,
1152 0xFDFD000000000000ULL,
1153 0xFD00000000000000ULL
1154 },
1155 {
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFDFDULL,
1158 0xFDFDFDFDFDFDFD00ULL,
1159 0xFDFDFDFDFDFD0000ULL,
1160 0xFDFDFDFDFD000000ULL,
1161 0xFDFDFDFD00000000ULL,
1162 0xFDFDFD0000000000ULL,
1163 0xFDFD000000000000ULL
1164 },
1165 {
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFDFDULL,
1169 0xFDFDFDFDFDFDFD00ULL,
1170 0xFDFDFDFDFDFD0000ULL,
1171 0xFDFDFDFDFD000000ULL,
1172 0xFDFDFDFD00000000ULL,
1173 0xFDFDFD0000000000ULL
1174 },
1175 {
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFDFDULL,
1180 0xFDFDFDFDFDFDFD00ULL,
1181 0xFDFDFDFDFDFD0000ULL,
1182 0xFDFDFDFDFD000000ULL,
1183 0xFDFDFDFD00000000ULL
1184 },
1185 {
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFDFDULL,
1191 0xFDFDFDFDFDFDFD00ULL,
1192 0xFDFDFDFDFDFD0000ULL,
1193 0xFDFDFDFDFD000000ULL
1194 },
1195 {
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL,
1201 0xFDFDFDFDFDFDFDFDULL,
1202 0xFDFDFDFDFDFDFD00ULL,
1203 0xFDFDFDFDFDFD0000ULL
1204 },
1205 {
1206 0xFDFDFDFDFDFDFDFDULL,
1207 0xFDFDFDFDFDFDFDFDULL,
1208 0xFDFDFDFDFDFDFDFDULL,
1209 0xFDFDFDFDFDFDFDFDULL,
1210 0xFDFDFDFDFDFDFDFDULL,
1211 0xFDFDFDFDFDFDFDFDULL,
1212 0xFDFDFDFDFDFDFDFDULL,
1213 0xFDFDFDFDFDFDFD00ULL
1214 },
1215 {
1216 0xFDFDFDFDFDFDFDFDULL,
1217 0xFDFDFDFDFDFDFDFDULL,
1218 0xFDFDFDFDFDFDFDFDULL,
1219 0xFDFDFDFDFDFDFDFDULL,
1220 0xFDFDFDFDFDFDFDFDULL,
1221 0xFDFDFDFDFDFDFDFDULL,
1222 0xFDFDFDFDFDFDFDFDULL,
1223 0xFDFDFDFDFDFDFDFDULL
1224 }
1225 },
1226 {
1227 {
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL,
1233 0x0000000000000000ULL,
1234 0x0000000000000000ULL,
1235 0x0000000000000000ULL
1236 },
1237 {
1238 0x00000000000000FDULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL,
1243 0x0000000000000000ULL,
1244 0x0000000000000000ULL,
1245 0x0000000000000000ULL
1246 },
1247 {
1248 0x000000000000FDFDULL,
1249 0x00000000000000FDULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL,
1253 0x0000000000000000ULL,
1254 0x0000000000000000ULL,
1255 0x0000000000000000ULL
1256 },
1257 {
1258 0x0000000000FDFDFDULL,
1259 0x000000000000FDFDULL,
1260 0x00000000000000FDULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL,
1263 0x0000000000000000ULL,
1264 0x0000000000000000ULL,
1265 0x0000000000000000ULL
1266 },
1267 {
1268 0x00000000FDFDFDFDULL,
1269 0x0000000000FDFDFDULL,
1270 0x000000000000FDFDULL,
1271 0x00000000000000FDULL,
1272 0x0000000000000000ULL,
1273 0x0000000000000000ULL,
1274 0x0000000000000000ULL,
1275 0x0000000000000000ULL
1276 },
1277 {
1278 0x000000FDFDFDFDFDULL,
1279 0x00000000FDFDFDFDULL,
1280 0x0000000000FDFDFDULL,
1281 0x000000000000FDFDULL,
1282 0x00000000000000FDULL,
1283 0x0000000000000000ULL,
1284 0x0000000000000000ULL,
1285 0x0000000000000000ULL
1286 },
1287 {
1288 0x0000FDFDFDFDFDFDULL,
1289 0x000000FDFDFDFDFDULL,
1290 0x00000000FDFDFDFDULL,
1291 0x0000000000FDFDFDULL,
1292 0x000000000000FDFDULL,
1293 0x00000000000000FDULL,
1294 0x0000000000000000ULL,
1295 0x0000000000000000ULL
1296 },
1297 {
1298 0x00FDFDFDFDFDFDFDULL,
1299 0x0000FDFDFDFDFDFDULL,
1300 0x000000FDFDFDFDFDULL,
1301 0x00000000FDFDFDFDULL,
1302 0x0000000000FDFDFDULL,
1303 0x000000000000FDFDULL,
1304 0x00000000000000FDULL,
1305 0x0000000000000000ULL
1306 },
1307 {
1308 0xFDFDFDFDFDFDFDFDULL,
1309 0x00FDFDFDFDFDFDFDULL,
1310 0x0000FDFDFDFDFDFDULL,
1311 0x000000FDFDFDFDFDULL,
1312 0x00000000FDFDFDFDULL,
1313 0x0000000000FDFDFDULL,
1314 0x000000000000FDFDULL,
1315 0x00000000000000FDULL
1316 },
1317 {
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0xFDFDFDFDFDFDFDFDULL,
1320 0x00FDFDFDFDFDFDFDULL,
1321 0x0000FDFDFDFDFDFDULL,
1322 0x000000FDFDFDFDFDULL,
1323 0x00000000FDFDFDFDULL,
1324 0x0000000000FDFDFDULL,
1325 0x000000000000FDFDULL
1326 },
1327 {
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0xFDFDFDFDFDFDFDFDULL,
1331 0x00FDFDFDFDFDFDFDULL,
1332 0x0000FDFDFDFDFDFDULL,
1333 0x000000FDFDFDFDFDULL,
1334 0x00000000FDFDFDFDULL,
1335 0x0000000000FDFDFDULL
1336 },
1337 {
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0xFDFDFDFDFDFDFDFDULL,
1342 0x00FDFDFDFDFDFDFDULL,
1343 0x0000FDFDFDFDFDFDULL,
1344 0x000000FDFDFDFDFDULL,
1345 0x00000000FDFDFDFDULL
1346 },
1347 {
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0xFDFDFDFDFDFDFDFDULL,
1353 0x00FDFDFDFDFDFDFDULL,
1354 0x0000FDFDFDFDFDFDULL,
1355 0x000000FDFDFDFDFDULL
1356 },
1357 {
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL,
1363 0xFDFDFDFDFDFDFDFDULL,
1364 0x00FDFDFDFDFDFDFDULL,
1365 0x0000FDFDFDFDFDFDULL
1366 },
1367 {
1368 0xFDFDFDFDFDFDFDFDULL,
1369 0xFDFDFDFDFDFDFDFDULL,
1370 0xFDFDFDFDFDFDFDFDULL,
1371 0xFDFDFDFDFDFDFDFDULL,
1372 0xFDFDFDFDFDFDFDFDULL,
1373 0xFDFDFDFDFDFDFDFDULL,
1374 0xFDFDFDFDFDFDFDFDULL,
1375 0x00FDFDFDFDFDFDFDULL
1376 },
1377 {
1378 0xFDFDFDFDFDFDFDFDULL,
1379 0xFDFDFDFDFDFDFDFDULL,
1380 0xFDFDFDFDFDFDFDFDULL,
1381 0xFDFDFDFDFDFDFDFDULL,
1382 0xFDFDFDFDFDFDFDFDULL,
1383 0xFDFDFDFDFDFDFDFDULL,
1384 0xFDFDFDFDFDFDFDFDULL,
1385 0xFDFDFDFDFDFDFDFDULL
1386 }
1387 },
1388 {
1389 {
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0x0000000000000000ULL,
1394 0x0000000000000000ULL,
1395 0x0000000000000000ULL,
1396 0x0000000000000000ULL,
1397 0x0000000000000000ULL
1398 },
1399 {
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0x0000000000000000ULL,
1403 0x0000000000000000ULL,
1404 0x0000000000000000ULL,
1405 0x0000000000000000ULL,
1406 0x0000000000000000ULL,
1407 0xFD00000000000000ULL
1408 },
1409 {
1410 0x0000000000000000ULL,
1411 0x0000000000000000ULL,
1412 0x0000000000000000ULL,
1413 0x0000000000000000ULL,
1414 0x0000000000000000ULL,
1415 0x0000000000000000ULL,
1416 0xFD00000000000000ULL,
1417 0xFDFD000000000000ULL
1418 },
1419 {
1420 0x0000000000000000ULL,
1421 0x0000000000000000ULL,
1422 0x0000000000000000ULL,
1423 0x0000000000000000ULL,
1424 0x0000000000000000ULL,
1425 0xFD00000000000000ULL,
1426 0xFDFD000000000000ULL,
1427 0xFDFDFD0000000000ULL
1428 },
1429 {
1430 0x0000000000000000ULL,
1431 0x0000000000000000ULL,
1432 0x0000000000000000ULL,
1433 0x0000000000000000ULL,
1434 0xFD00000000000000ULL,
1435 0xFDFD000000000000ULL,
1436 0xFDFDFD0000000000ULL,
1437 0xFDFDFDFD00000000ULL
1438 },
1439 {
1440 0x0000000000000000ULL,
1441 0x0000000000000000ULL,
1442 0x0000000000000000ULL,
1443 0xFD00000000000000ULL,
1444 0xFDFD000000000000ULL,
1445 0xFDFDFD0000000000ULL,
1446 0xFDFDFDFD00000000ULL,
1447 0xFDFDFDFDFD000000ULL
1448 },
1449 {
1450 0x0000000000000000ULL,
1451 0x0000000000000000ULL,
1452 0xFD00000000000000ULL,
1453 0xFDFD000000000000ULL,
1454 0xFDFDFD0000000000ULL,
1455 0xFDFDFDFD00000000ULL,
1456 0xFDFDFDFDFD000000ULL,
1457 0xFDFDFDFDFDFD0000ULL
1458 },
1459 {
1460 0x0000000000000000ULL,
1461 0xFD00000000000000ULL,
1462 0xFDFD000000000000ULL,
1463 0xFDFDFD0000000000ULL,
1464 0xFDFDFDFD00000000ULL,
1465 0xFDFDFDFDFD000000ULL,
1466 0xFDFDFDFDFDFD0000ULL,
1467 0xFDFDFDFDFDFDFD00ULL
1468 },
1469 {
1470 0xFD00000000000000ULL,
1471 0xFDFD000000000000ULL,
1472 0xFDFDFD0000000000ULL,
1473 0xFDFDFDFD00000000ULL,
1474 0xFDFDFDFDFD000000ULL,
1475 0xFDFDFDFDFDFD0000ULL,
1476 0xFDFDFDFDFDFDFD00ULL,
1477 0xFDFDFDFDFDFDFDFDULL
1478 },
1479 {
1480 0xFDFD000000000000ULL,
1481 0xFDFDFD0000000000ULL,
1482 0xFDFDFDFD00000000ULL,
1483 0xFDFDFDFDFD000000ULL,
1484 0xFDFDFDFDFDFD0000ULL,
1485 0xFDFDFDFDFDFDFD00ULL,
1486 0xFDFDFDFDFDFDFDFDULL,
1487 0xFDFDFDFDFDFDFDFDULL
1488 },
1489 {
1490 0xFDFDFD0000000000ULL,
1491 0xFDFDFDFD00000000ULL,
1492 0xFDFDFDFDFD000000ULL,
1493 0xFDFDFDFDFDFD0000ULL,
1494 0xFDFDFDFDFDFDFD00ULL,
1495 0xFDFDFDFDFDFDFDFDULL,
1496 0xFDFDFDFDFDFDFDFDULL,
1497 0xFDFDFDFDFDFDFDFDULL
1498 },
1499 {
1500 0xFDFDFDFD00000000ULL,
1501 0xFDFDFDFDFD000000ULL,
1502 0xFDFDFDFDFDFD0000ULL,
1503 0xFDFDFDFDFDFDFD00ULL,
1504 0xFDFDFDFDFDFDFDFDULL,
1505 0xFDFDFDFDFDFDFDFDULL,
1506 0xFDFDFDFDFDFDFDFDULL,
1507 0xFDFDFDFDFDFDFDFDULL
1508 },
1509 {
1510 0xFDFDFDFDFD000000ULL,
1511 0xFDFDFDFDFDFD0000ULL,
1512 0xFDFDFDFDFDFDFD00ULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL,
1515 0xFDFDFDFDFDFDFDFDULL,
1516 0xFDFDFDFDFDFDFDFDULL,
1517 0xFDFDFDFDFDFDFDFDULL
1518 },
1519 {
1520 0xFDFDFDFDFDFD0000ULL,
1521 0xFDFDFDFDFDFDFD00ULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL,
1525 0xFDFDFDFDFDFDFDFDULL,
1526 0xFDFDFDFDFDFDFDFDULL,
1527 0xFDFDFDFDFDFDFDFDULL
1528 },
1529 {
1530 0xFDFDFDFDFDFDFD00ULL,
1531 0xFDFDFDFDFDFDFDFDULL,
1532 0xFDFDFDFDFDFDFDFDULL,
1533 0xFDFDFDFDFDFDFDFDULL,
1534 0xFDFDFDFDFDFDFDFDULL,
1535 0xFDFDFDFDFDFDFDFDULL,
1536 0xFDFDFDFDFDFDFDFDULL,
1537 0xFDFDFDFDFDFDFDFDULL
1538 },
1539 {
1540 0xFDFDFDFDFDFDFDFDULL,
1541 0xFDFDFDFDFDFDFDFDULL,
1542 0xFDFDFDFDFDFDFDFDULL,
1543 0xFDFDFDFDFDFDFDFDULL,
1544 0xFDFDFDFDFDFDFDFDULL,
1545 0xFDFDFDFDFDFDFDFDULL,
1546 0xFDFDFDFDFDFDFDFDULL,
1547 0xFDFDFDFDFDFDFDFDULL
1548 }
1549 },
1550 {
1551 {
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x0000000000000000ULL,
1556 0x0000000000000000ULL,
1557 0x0000000000000000ULL,
1558 0x0000000000000000ULL,
1559 0x0000000000000000ULL
1560 },
1561 {
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x0000000000000000ULL,
1565 0x0000000000000000ULL,
1566 0x0000000000000000ULL,
1567 0x0000000000000000ULL,
1568 0x0000000000000000ULL,
1569 0x00000000000000FDULL
1570 },
1571 {
1572 0x0000000000000000ULL,
1573 0x0000000000000000ULL,
1574 0x0000000000000000ULL,
1575 0x0000000000000000ULL,
1576 0x0000000000000000ULL,
1577 0x0000000000000000ULL,
1578 0x00000000000000FDULL,
1579 0x000000000000FDFDULL
1580 },
1581 {
1582 0x0000000000000000ULL,
1583 0x0000000000000000ULL,
1584 0x0000000000000000ULL,
1585 0x0000000000000000ULL,
1586 0x0000000000000000ULL,
1587 0x00000000000000FDULL,
1588 0x000000000000FDFDULL,
1589 0x0000000000FDFDFDULL
1590 },
1591 {
1592 0x0000000000000000ULL,
1593 0x0000000000000000ULL,
1594 0x0000000000000000ULL,
1595 0x0000000000000000ULL,
1596 0x00000000000000FDULL,
1597 0x000000000000FDFDULL,
1598 0x0000000000FDFDFDULL,
1599 0x00000000FDFDFDFDULL
1600 },
1601 {
1602 0x0000000000000000ULL,
1603 0x0000000000000000ULL,
1604 0x0000000000000000ULL,
1605 0x00000000000000FDULL,
1606 0x000000000000FDFDULL,
1607 0x0000000000FDFDFDULL,
1608 0x00000000FDFDFDFDULL,
1609 0x000000FDFDFDFDFDULL
1610 },
1611 {
1612 0x0000000000000000ULL,
1613 0x0000000000000000ULL,
1614 0x00000000000000FDULL,
1615 0x000000000000FDFDULL,
1616 0x0000000000FDFDFDULL,
1617 0x00000000FDFDFDFDULL,
1618 0x000000FDFDFDFDFDULL,
1619 0x0000FDFDFDFDFDFDULL
1620 },
1621 {
1622 0x0000000000000000ULL,
1623 0x00000000000000FDULL,
1624 0x000000000000FDFDULL,
1625 0x0000000000FDFDFDULL,
1626 0x00000000FDFDFDFDULL,
1627 0x000000FDFDFDFDFDULL,
1628 0x0000FDFDFDFDFDFDULL,
1629 0x00FDFDFDFDFDFDFDULL
1630 },
1631 {
1632 0x00000000000000FDULL,
1633 0x000000000000FDFDULL,
1634 0x0000000000FDFDFDULL,
1635 0x00000000FDFDFDFDULL,
1636 0x000000FDFDFDFDFDULL,
1637 0x0000FDFDFDFDFDFDULL,
1638 0x00FDFDFDFDFDFDFDULL,
1639 0xFDFDFDFDFDFDFDFDULL
1640 },
1641 {
1642 0x000000000000FDFDULL,
1643 0x0000000000FDFDFDULL,
1644 0x00000000FDFDFDFDULL,
1645 0x000000FDFDFDFDFDULL,
1646 0x0000FDFDFDFDFDFDULL,
1647 0x00FDFDFDFDFDFDFDULL,
1648 0xFDFDFDFDFDFDFDFDULL,
1649 0xFDFDFDFDFDFDFDFDULL
1650 },
1651 {
1652 0x0000000000FDFDFDULL,
1653 0x00000000FDFDFDFDULL,
1654 0x000000FDFDFDFDFDULL,
1655 0x0000FDFDFDFDFDFDULL,
1656 0x00FDFDFDFDFDFDFDULL,
1657 0xFDFDFDFDFDFDFDFDULL,
1658 0xFDFDFDFDFDFDFDFDULL,
1659 0xFDFDFDFDFDFDFDFDULL
1660 },
1661 {
1662 0x00000000FDFDFDFDULL,
1663 0x000000FDFDFDFDFDULL,
1664 0x0000FDFDFDFDFDFDULL,
1665 0x00FDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL,
1667 0xFDFDFDFDFDFDFDFDULL,
1668 0xFDFDFDFDFDFDFDFDULL,
1669 0xFDFDFDFDFDFDFDFDULL
1670 },
1671 {
1672 0x000000FDFDFDFDFDULL,
1673 0x0000FDFDFDFDFDFDULL,
1674 0x00FDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL,
1677 0xFDFDFDFDFDFDFDFDULL,
1678 0xFDFDFDFDFDFDFDFDULL,
1679 0xFDFDFDFDFDFDFDFDULL
1680 },
1681 {
1682 0x0000FDFDFDFDFDFDULL,
1683 0x00FDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL,
1687 0xFDFDFDFDFDFDFDFDULL,
1688 0xFDFDFDFDFDFDFDFDULL,
1689 0xFDFDFDFDFDFDFDFDULL
1690 },
1691 {
1692 0x00FDFDFDFDFDFDFDULL,
1693 0xFDFDFDFDFDFDFDFDULL,
1694 0xFDFDFDFDFDFDFDFDULL,
1695 0xFDFDFDFDFDFDFDFDULL,
1696 0xFDFDFDFDFDFDFDFDULL,
1697 0xFDFDFDFDFDFDFDFDULL,
1698 0xFDFDFDFDFDFDFDFDULL,
1699 0xFDFDFDFDFDFDFDFDULL
1700 },
1701 {
1702 0xFDFDFDFDFDFDFDFDULL,
1703 0xFDFDFDFDFDFDFDFDULL,
1704 0xFDFDFDFDFDFDFDFDULL,
1705 0xFDFDFDFDFDFDFDFDULL,
1706 0xFDFDFDFDFDFDFDFDULL,
1707 0xFDFDFDFDFDFDFDFDULL,
1708 0xFDFDFDFDFDFDFDFDULL,
1709 0xFDFDFDFDFDFDFDFDULL
1710 }
1711 }
1712 };
1713
1714 int32_t black_opening_count=0;
1715 int32_t black_opening_x,black_opening_y;
1716 int32_t black_opening_shape;
1717
1718 1505 int32_t choose_opening_shape()
1719 {
1720 // First, count how many bits are set
1721 1505 int32_t numBits=0;
1722 int32_t bitCounter;
1723
1724
2/2
✓ Branch 0 taken 7525 times.
✓ Branch 1 taken 1505 times.
9030 for(int32_t i=0; i<bosMAX; i++)
1725 {
1726
2/2
✓ Branch 0 taken 5804 times.
✓ Branch 1 taken 1721 times.
7525 if(COOLSCROLL&(1<<i))
1727 1721 numBits++;
1728 7525 }
1729
1730 // Shouldn't happen...
1731
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
1505 if(numBits==0)
1732 return bosCIRCLE;
1733
1734 // Pick a bit
1735 1505 bitCounter=zc_rand()%numBits+1;
1736
1737
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 26 times.
2016 for(int32_t i=0; i<bosMAX; i++)
1738 {
1739 // If this bit is set, decrement the bit counter
1740
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1635 times.
1990 if(COOLSCROLL&(1<<i))
1741 1635 bitCounter--;
1742
1743 // When the counter hits 0, return a value based on
1744 // which bit it stopped on.
1745 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1746
2/2
✓ Branch 0 taken 1479 times.
✓ Branch 1 taken 511 times.
1990 if(bitCounter==0)
1747 1479 return i;
1748 511 }
1749
1750 // Shouldn't be necessary, but the compiler might complain, at least
1751 26 return bosCIRCLE;
1752 1505 }
1753
1754 396 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1755 {
1756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1757
1758 396 int32_t w=256, h=224;
1759 396 int32_t blockrows=28, blockcolumns=32;
1760 396 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1761
1762
2/2
✓ Branch 0 taken 11088 times.
✓ Branch 1 taken 396 times.
11484 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1763 {
1764
2/2
✓ Branch 0 taken 354816 times.
✓ Branch 1 taken 11088 times.
365904 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1765 {
1766
2/2
✓ Branch 0 taken 147229 times.
✓ Branch 1 taken 207587 times.
354816 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1767 354816 }
1768 11088 }
1769
1770 396 black_opening_count = 66;
1771 396 black_opening_x = x;
1772 396 black_opening_y = y;
1773 396 lensclk = 0;
1774 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1775
1776
1777
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(black_opening_shape == bosFADEBLACK)
1778 {
1779 refreshTints();
1780 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1781 }
1782
1/2
✓ Branch 0 taken 396 times.
✗ Branch 1 not taken.
396 if(wait)
1783 {
1784 FFCore.warpScriptCheck();
1785 for(int32_t i=0; i<66; i++)
1786 {
1787 draw_screen(tmpscr);
1788 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1789 advanceframe(true);
1790
1791 if(Quit)
1792 {
1793 break;
1794 }
1795 }
1796 }
1797 396 }
1798
1799 1109 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1800 {
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1109 times.
1109 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1802
1803 1109 int32_t w=256, h=224;
1804 1109 int32_t blockrows=28, blockcolumns=32;
1805 1109 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1806
1807
2/2
✓ Branch 0 taken 31052 times.
✓ Branch 1 taken 1109 times.
32161 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1808 {
1809
2/2
✓ Branch 0 taken 993664 times.
✓ Branch 1 taken 31052 times.
1024716 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1810 {
1811
2/2
✓ Branch 0 taken 506127 times.
✓ Branch 1 taken 487537 times.
993664 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1812 993664 }
1813 31052 }
1814
1815 1109 black_opening_count = -66;
1816 1109 black_opening_x = x;
1817 1109 black_opening_y = y;
1818 1109 lensclk = 0;
1819
1/2
✓ Branch 0 taken 1109 times.
✗ Branch 1 not taken.
1109 if(black_opening_shape == bosFADEBLACK)
1820 {
1821 refreshTints();
1822 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1823 }
1824
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 910 times.
1109 if(wait)
1825 {
1826 910 FFCore.warpScriptCheck();
1827
2/2
✓ Branch 0 taken 910 times.
✓ Branch 1 taken 60060 times.
60970 for(int32_t i=0; i<66; i++)
1828 {
1829 60060 draw_screen(tmpscr);
1830 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
1831 60060 advanceframe(true);
1832
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60060 times.
60060 if(Quit)
1834 {
1835 break;
1836 }
1837 60060 }
1838 910 }
1839 1109 }
1840
1841 99330 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1842 {
1843 99330 clear_to_color(tmp_scr,BLACK);
1844 99330 int32_t w=256, h=224;
1845
1846
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 858 times.
✓ Branch 2 taken 660 times.
✓ Branch 3 taken 7656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90156 times.
99330 switch(black_opening_shape)
1847 {
1848 case bosOVAL:
1849 {
1850 858 double new_w=(w/2)+abs(w/2-x);
1851 858 double new_h=(h/2)+abs(h/2-y);
1852 858 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1853 858 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1854 858 break;
1855 }
1856
1857 case bosTRIANGLE:
1858 {
1859 660 double new_w=(w/2)+abs(w/2-x);
1860 660 double new_h=(h/2)+abs(h/2-y);
1861 660 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1862 660 double P2= (PI/2);
1863 660 double P23=(2*PI/3);
1864 660 double P43=(4*PI/3);
1865 660 double Pa= (-4*PI*a/(3*max_a));
1866 660 double angle=P2+Pa;
1867 660 double a0=angle;
1868 660 double a2=angle+P23;
1869 660 double a4=angle+P43;
1870 1320 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1871 660 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1872 660 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1873 0);
1874 660 break;
1875 }
1876
1877 case bosSMAS:
1878 {
1879
2/2
✓ Branch 0 taken 4158 times.
✓ Branch 1 taken 3498 times.
7656 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1880
1881
2/2
✓ Branch 0 taken 214368 times.
✓ Branch 1 taken 7656 times.
222024 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1882 {
1883
2/2
✓ Branch 0 taken 1714944 times.
✓ Branch 1 taken 214368 times.
1929312 for(int32_t linerow=0; linerow<8; ++linerow)
1884 {
1885 1714944 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1886
1887
2/2
✓ Branch 0 taken 54878208 times.
✓ Branch 1 taken 1714944 times.
56593152 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1888 {
1889 164634624 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1890
6/6
✓ Branch 0 taken 39546648 times.
✓ Branch 1 taken 15331560 times.
✓ Branch 2 taken 35934032 times.
✓ Branch 3 taken 18944176 times.
✓ Branch 4 taken 20602472 times.
✓ Branch 5 taken 15331560 times.
54878208 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1891 54878208 [linerow];
1892 54878208 ++triangleline;
1893
1894
2/2
✓ Branch 0 taken 48018432 times.
✓ Branch 1 taken 6859776 times.
54878208 if(linerow==0)
1895 {
1896 6859776 }
1897 54878208 }
1898 1714944 }
1899 214368 }
1900
1901 7656 break;
1902 }
1903
1904 case bosFADEBLACK:
1905 {
1906 if(black_opening_count<0)
1907 {
1908 black_fade(zc_min(-black_opening_count,63));
1909 }
1910 else if(black_opening_count>0)
1911 {
1912 black_fade(63-zc_max(black_opening_count-3,0));
1913 }
1914 else black_fade(0);
1915 return; //no blitting from tmp_scr!
1916 }
1917
1918 90156 case bosCIRCLE:
1919 default:
1920 {
1921 90156 double new_w=(w/2)+abs(w/2-x);
1922 90156 double new_h=(h/2)+abs(h/2-y);
1923 90156 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1924 //circlefill(tmp_scr,x,y,a<<3,0);
1925 90156 circlefill(tmp_scr,x,y,r,0);
1926 90156 break;
1927 }
1928 }
1929
1930 99330 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1931 99330 }
1932
1933
1934 void black_fade(int32_t fadeamnt)
1935 {
1936 for(int32_t i=0; i < 0xEF; i++)
1937 {
1938 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1939 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1940 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1941 }
1942
1943 refreshpal = true;
1944 }
1945
1946 //----------------------------------------------------------------
1947
1948 44454677 bool item_disabled(int32_t item) //is this item disabled?
1949 {
1950
2/2
✓ Branch 0 taken 1799270 times.
✓ Branch 1 taken 42655407 times.
44454677 return (unsigned(item) < MAXITEMS && game->items_off[item] != 0);
1951 }
1952
1953 7617044 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1954 {
1955
2/2
✓ Branch 0 taken 135248 times.
✓ Branch 1 taken 7481796 times.
7617044 if(current_item(item_type, true) >=item)
1956 {
1957 135248 return true;
1958 }
1959
1960 7481796 return false;
1961 7617044 }
1962
1963 31049643 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1964 {
1965
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052589 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3220277 times.
✓ Branch 6 taken 16167592 times.
✓ Branch 7 taken 5493498 times.
✓ Branch 8 taken 115687 times.
31049643 switch(item_type)
1966 {
1967 case itype_bomb:
1968 case itype_sbomb:
1969 {
1970 int32_t itemid = getItemID(itemsbuf, item_type, it);
1971
1972 if(itemid == -1)
1973 return false;
1974
1975 return (game->get_item(itemid));
1976 }
1977
1978 case itype_clock:
1979 {
1980 6052589 int32_t itemid = getItemID(itemsbuf, item_type, it);
1981
1982
2/4
✓ Branch 0 taken 6052589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6052589 times.
✗ Branch 3 not taken.
6052589 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1983 return (game->get_item(itemid));
1984 6052589 return Hero.getClock()?1:0;
1985 }
1986
1987 case itype_key:
1988 return (game->get_keys()>0);
1989
1990 case itype_magiccontainer:
1991 return (game->get_maxmagic()>=game->get_mp_per_block());
1992
1993 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1994 {
1995
1/3
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
3220277 switch(it)
1996 {
1997 case -2:
1998 {
1999 for(int32_t i=0; i<MAXLEVELS; i++)
2000 {
2001 if(game->lvlitems[i]&liTRIFORCE)
2002 {
2003 return true;
2004 }
2005 }
2006
2007 return false;
2008 }
2009
2010 case -1:
2011 return (game->lvlitems[dlevel]&liTRIFORCE);
2012
2013 default:
2014
2/4
✓ Branch 0 taken 3220277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3220277 times.
3220277 if(it>=0&&it<MAXLEVELS)
2015 {
2016 3220277 return (game->lvlitems[it]&liTRIFORCE);
2017 }
2018
2019 break;
2020 }
2021
2022 return 0;
2023 }
2024
2025 case itype_map: //it: -2=any, -1=current level, other=that level
2026 {
2027
1/3
✓ Branch 0 taken 16167592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
16167592 switch(it)
2028 {
2029 case -2:
2030 {
2031 for(int32_t i=0; i<MAXLEVELS; i++)
2032 {
2033 if(game->lvlitems[i]&liMAP)
2034 {
2035 return true;
2036 }
2037 }
2038
2039 return false;
2040 }
2041
2042 case -1:
2043 return (game->lvlitems[dlevel]&liMAP)!=0;
2044
2045 default:
2046
2/4
✓ Branch 0 taken 16167592 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16167592 times.
16167592 if(it>=0&&it<MAXLEVELS)
2047 {
2048 16167592 return (game->lvlitems[it]&liMAP)!=0;
2049 }
2050
2051 break;
2052 }
2053
2054 return 0;
2055 }
2056
2057 case itype_compass: //it: -2=any, -1=current level, other=that level
2058 {
2059
1/3
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
5493498 switch(it)
2060 {
2061 case -2:
2062 {
2063 for(int32_t i=0; i<MAXLEVELS; i++)
2064 {
2065 if(game->lvlitems[i]&liCOMPASS)
2066 {
2067 return true;
2068 }
2069 }
2070
2071 return false;
2072 }
2073
2074 case -1:
2075 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2076
2077 default:
2078
2/4
✓ Branch 0 taken 5493498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5493498 times.
✗ Branch 3 not taken.
5493498 if(it>=0&&it<MAXLEVELS)
2079 {
2080 5493498 return (game->lvlitems[it]&liCOMPASS)!=0;
2081 }
2082
2083 break;
2084 }
2085 return 0;
2086 }
2087
2088 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2089 {
2090
1/3
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
115687 switch(it)
2091 {
2092 case -2:
2093 {
2094 for(int32_t i=0; i<MAXLEVELS; i++)
2095 {
2096 if(game->lvlitems[i]&liBOSSKEY)
2097 {
2098 return true;
2099 }
2100 }
2101
2102 return false;
2103 }
2104
2105 case -1:
2106 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2107
2108 default:
2109
2/4
✓ Branch 0 taken 115687 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 115687 times.
115687 if(it>=0&&it<MAXLEVELS)
2110 {
2111 115687 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2112 }
2113 break;
2114 }
2115 return 0;
2116 }
2117
2118 default:
2119 //it=(1<<(it-1));
2120 /*if (item_type>=itype_max)
2121 {
2122 enter_sys_pal();
2123 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
2124 exit_sys_pal();
2125
2126 return false;
2127 }*/
2128 int32_t itemid = getItemID(itemsbuf, item_type, it);
2129
2130 if(itemid == -1)
2131 return false;
2132
2133 return game->get_item(itemid);
2134 }
2135 31049643 }
2136
2137
2138 100001887 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2139 {
2140
9/9
✓ Branch 0 taken 6052589 times.
✓ Branch 1 taken 51581175 times.
✓ Branch 2 taken 6052589 times.
✓ Branch 3 taken 6052589 times.
✓ Branch 4 taken 6052589 times.
✓ Branch 5 taken 6052589 times.
✓ Branch 6 taken 6052589 times.
✓ Branch 7 taken 6052589 times.
✓ Branch 8 taken 6052589 times.
100001887 switch(item_type)
2141 {
2142 case itype_clock:
2143 {
2144 6052589 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2145
2146
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6052589 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6052589 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2147 return itemsbuf[maxid].fam_type;
2148
2149 6052589 return has_item(itype_clock,1) ? 1 : 0;
2150 }
2151
2152 case itype_key:
2153 6052589 return game->get_keys();
2154
2155 case itype_lkey:
2156 6052589 return game->lvlkeys[get_dlevel()];
2157
2158 case itype_magiccontainer:
2159 6052589 return game->get_maxmagic()/game->get_mp_per_block();
2160
2161 case itype_triforcepiece:
2162 {
2163 6052589 int32_t count=0;
2164
2165
2/2
✓ Branch 0 taken 3098925568 times.
✓ Branch 1 taken 6052589 times.
3104978157 for(int32_t i=0; i<MAXLEVELS; i++)
2166 {
2167 3098925568 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2168 3098925568 }
2169
2170 6052589 return count;
2171 }
2172
2173 case itype_map:
2174 {
2175 6052589 int32_t count=0;
2176
2177
2/2
✓ Branch 0 taken 3098925568 times.
✓ Branch 1 taken 6052589 times.
3104978157 for(int32_t i=0; i<MAXLEVELS; i++)
2178 {
2179 3098925568 count+=(game->lvlitems[i]&liMAP)?1:0;
2180 3098925568 }
2181
2182 6052589 return count;
2183 }
2184
2185 case itype_compass:
2186 {
2187 6052589 int32_t count=0;
2188
2189
2/2
✓ Branch 0 taken 3098925568 times.
✓ Branch 1 taken 6052589 times.
3104978157 for(int32_t i=0; i<MAXLEVELS; i++)
2190 {
2191 3098925568 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2192 3098925568 }
2193
2194 6052589 return count;
2195 }
2196
2197 case itype_bosskey:
2198 {
2199 6052589 int32_t count=0;
2200
2201
2/2
✓ Branch 0 taken 3098925568 times.
✓ Branch 1 taken 6052589 times.
3104978157 for(int32_t i=0; i<MAXLEVELS; i++)
2202 {
2203 3098925568 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2204 3098925568 }
2205
2206 6052589 return count;
2207 }
2208
2209 default:
2210 51581175 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2211
2212
2/2
✓ Branch 0 taken 9875888 times.
✓ Branch 1 taken 41705287 times.
51581175 if(maxid == -1)
2213 41705287 return 0;
2214
2215 9875888 return itemsbuf[maxid].fam_type;
2216 }
2217 100001887 }
2218
2219 92384843 int32_t current_item(int32_t item_type) //item currently being used
2220 {
2221 92384843 return current_item(item_type, true);
2222 }
2223
2224 114 std::map<int32_t, int32_t> itemcache;
2225 114 std::map<int32_t, int32_t> itemcache_cost;
2226
2227 void removeFromItemCache(int32_t itemclass)
2228 {
2229 itemcache.erase(itemclass);
2230 itemcache_cost.erase(itemclass);
2231 }
2232
2233 5861247 void flushItemCache(bool justcost)
2234 {
2235 5861247 itemcache_cost.clear();
2236
2/2
✓ Branch 0 taken 5831228 times.
✓ Branch 1 taken 30019 times.
5861247 if(!justcost)
2237 30019 itemcache.clear();
2238
2/2
✓ Branch 0 taken 5830904 times.
✓ Branch 1 taken 324 times.
5831228 else if(replay_version_check(0,19))
2239 5830904 return;
2240
2241 //also fix the active subscreen if items were deleted -DD
2242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30343 times.
30343 if(game != NULL)
2243 {
2244 30343 verifyBothWeapons();
2245 30343 refresh_subscr_items();
2246 30343 }
2247 5861247 }
2248
2249 // This is used often, so it should be as direct as possible.
2250 3375865963 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check, bool check_bunny)
2251 {
2252 3375865963 bool use_cost_cache = replay_version_check(19);
2253
2/2
✓ Branch 0 taken 3300310355 times.
✓ Branch 1 taken 75555608 times.
3375865963 if(jinx_check)
2254 {
2255
4/4
✓ Branch 0 taken 47349262 times.
✓ Branch 1 taken 28206346 times.
✓ Branch 2 taken 8273866 times.
✓ Branch 3 taken 39075396 times.
75555608 if(!(HeroSwordClk() || HeroItemClk()))
2256 39075396 jinx_check = false; //not jinxed
2257 75555608 }
2258
2/2
✓ Branch 0 taken 1047446 times.
✓ Branch 1 taken 3374818517 times.
3375865963 if(!Hero.BunnyClock())
2259 3374818517 check_bunny = false; //not bunnied
2260
2/2
✓ Branch 0 taken 3346253699 times.
✓ Branch 1 taken 29612264 times.
3375865963 if(itemtype == itype_ring) checkmagic = true;
2261
4/4
✓ Branch 0 taken 3339385751 times.
✓ Branch 1 taken 36480212 times.
✓ Branch 2 taken 3308029381 times.
✓ Branch 3 taken 29262791 times.
6713158135 if (!jinx_check && !check_bunny
2262
3/4
✓ Branch 0 taken 3339385751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3337292172 times.
✓ Branch 3 taken 2093579 times.
3339385751 && (use_cost_cache || itemtype != itype_ring))
2263 {
2264
4/4
✓ Branch 0 taken 185296717 times.
✓ Branch 1 taken 3124826243 times.
✓ Branch 2 taken 185107907 times.
✓ Branch 3 taken 188810 times.
3310122960 auto& cache = checkmagic && use_cost_cache ? itemcache_cost : itemcache;
2265 3310122960 auto res = cache.find(itemtype);
2266
2267
2/2
✓ Branch 0 taken 3294801033 times.
✓ Branch 1 taken 15321927 times.
3310122960 if(res != cache.end())
2268 3294801033 return res->second;
2269 15321927 }
2270
2271 81064930 int32_t result = -1;
2272 81064930 int32_t highestlevel = -1;
2273
2274
2/2
✓ Branch 0 taken 20752622080 times.
✓ Branch 1 taken 81064930 times.
20833687010 for(int32_t i=0; i<MAXITEMS; i++)
2275 {
2276
5/6
✓ Branch 0 taken 1522449490 times.
✓ Branch 1 taken 19230172590 times.
✓ Branch 2 taken 21891584 times.
✓ Branch 3 taken 1500557906 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 21891584 times.
20752622080 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2277 {
2278
4/4
✓ Branch 0 taken 20047567 times.
✓ Branch 1 taken 1844017 times.
✓ Branch 2 taken 8694 times.
✓ Branch 3 taken 20038873 times.
21891584 if(checkmagic && itemtype != itype_magicring)
2279
2/2
✓ Branch 0 taken 20038703 times.
✓ Branch 1 taken 170 times.
20038873 if(!checkmagiccost(i))
2280 170 continue;
2281
6/6
✓ Branch 0 taken 18599157 times.
✓ Branch 1 taken 3292257 times.
✓ Branch 2 taken 243036 times.
✓ Branch 3 taken 3049221 times.
✓ Branch 4 taken 1846133 times.
✓ Branch 5 taken 1446124 times.
21891414 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1446124 times.
1446124 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2283 1446124 continue;
2284
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20445290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20445290 if(check_bunny && !checkbunny(i))
2285 continue;
2286
2287
2/2
✓ Branch 0 taken 280132 times.
✓ Branch 1 taken 20165158 times.
20445290 if(itemsbuf[i].fam_type >= highestlevel)
2288 {
2289 20165158 highestlevel = itemsbuf[i].fam_type;
2290 20165158 result=i;
2291 20165158 }
2292 20445290 }
2293 20751175786 }
2294
2295
3/4
✓ Branch 0 taken 44584718 times.
✓ Branch 1 taken 36480212 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44584718 times.
81064930 if(!(jinx_check || check_bunny)) //Can't cache jinx_check/check_bunny
2296 {
2297
2/2
✓ Branch 0 taken 4329 times.
✓ Branch 1 taken 44580389 times.
44584718 if (use_cost_cache)
2298 {
2299
2/2
✓ Branch 0 taken 2709 times.
✓ Branch 1 taken 1620 times.
4329 if (!checkmagic)
2300 1620 itemcache[itemtype] = result;
2301
5/6
✓ Branch 0 taken 1620 times.
✓ Branch 1 taken 2709 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1617 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
4329 if (checkmagic || result < 0 || checkmagiccost(result))
2302 4329 itemcache_cost[itemtype] = result;
2303 4329 }
2304 else
2305 {
2306 44580389 itemcache[itemtype] = result;
2307 }
2308 44584718 }
2309 81064930 return result;
2310 3375865963 }
2311
2312 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2313 3339829964 int32_t current_item_id(int32_t itype, bool checkmagic, bool jinx_check, bool check_bunny)
2314 {
2315
2/4
✓ Branch 0 taken 3339829964 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3339829964 times.
3339829964 if(itype < 0 || itype >= itype_max) return -1;
2316
1/2
✓ Branch 0 taken 3339829964 times.
✗ Branch 1 not taken.
3339829964 if(game->OverrideItems[itype] > -2)
2317 {
2318 auto ovid = game->OverrideItems[itype];
2319 if(ovid < 0 || ovid >= MAXITEMS)
2320 return -1;
2321 if(itemsbuf[ovid].family == itype)
2322 {
2323 if(itype == itype_magicring)
2324 checkmagic = false;
2325 else if(itype == itype_ring)
2326 checkmagic = true;
2327
2328 if(checkmagic && !checkmagiccost(ovid))
2329 return -1;
2330 if(jinx_check && !(itemsbuf[ovid].flags & ITEM_JINX_IMMUNE)
2331 && (usesSwordJinx(ovid) ? HeroSwordClk() : HeroItemClk()))
2332 return -1;
2333 return ovid;
2334 }
2335 }
2336 3339829964 auto ret = _c_item_id_internal(itype,checkmagic,jinx_check,check_bunny);
2337
2/2
✓ Branch 0 taken 39519609 times.
✓ Branch 1 taken 3300310355 times.
3339829964 if(!jinx_check) //If not already a jinx-immune-only check...
2338 {
2339 //And the player IS jinxed...
2340
4/4
✓ Branch 0 taken 3272446986 times.
✓ Branch 1 taken 27863369 times.
✓ Branch 2 taken 8172630 times.
✓ Branch 3 taken 3264274356 times.
3300310355 if(HeroSwordClk() || HeroItemClk())
2341 {
2342 //Then do a jinx-immune-only check here
2343 36035999 auto ret2 = _c_item_id_internal(itype,checkmagic,true,check_bunny);
2344 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2345 //Should NOT need a compat rule, as this should always return -1 in old quests.
2346
2/2
✓ Branch 0 taken 1261308 times.
✓ Branch 1 taken 34774691 times.
36035999 if(ret2 > -1) return ret2;
2347 34774691 }
2348 3299049047 }
2349 3338568656 return ret;
2350 3339829964 }
2351
2352 19331496 int32_t current_item_power(int32_t itemtype)
2353 {
2354 19331496 int32_t result = current_item_id(itemtype,true);
2355
2/2
✓ Branch 0 taken 14038742 times.
✓ Branch 1 taken 5292754 times.
19331496 return (result<0) ? 0 : itemsbuf[result].power;
2356 }
2357
2358 11 int32_t heart_container_id()
2359 {
2360
1/2
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
319 for(int32_t i=0; i<MAXITEMS; i++)
2361 {
2362
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 308 times.
319 if(itemsbuf[i].family == itype_heartcontainer)
2363 {
2364 11 return i;
2365 }
2366 308 }
2367 return -1;
2368 11 }
2369
2370 6052589 int32_t item_tile_mod()
2371 {
2372 6052589 int32_t tile=0;
2373
2374
2/2
✓ Branch 0 taken 1205578 times.
✓ Branch 1 taken 4847011 times.
6052589 if(game->get_bombs())
2375 {
2376 4847011 int32_t itemid = current_item_id(itype_bomb,false);
2377
3/4
✓ Branch 0 taken 4681842 times.
✓ Branch 1 taken 165169 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4681842 times.
4847011 if(itemid > -1 && checkbunny(itemid))
2378 4681842 tile+=itemsbuf[itemid].ltm;
2379 4847011 }
2380
2381
2/2
✓ Branch 0 taken 4538513 times.
✓ Branch 1 taken 1514076 times.
6052589 if(game->get_sbombs())
2382 {
2383 1514076 int32_t itemid = current_item_id(itype_sbomb,false);
2384
3/4
✓ Branch 0 taken 1512648 times.
✓ Branch 1 taken 1428 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1512648 times.
1514076 if(itemid > -1 && checkbunny(itemid))
2385 1512648 tile+=itemsbuf[itemid].ltm;
2386 1514076 }
2387
2388
2/2
✓ Branch 0 taken 5942889 times.
✓ Branch 1 taken 109700 times.
6052589 if(current_item(itype_clock))
2389 {
2390 109700 int32_t itemid =
2391
1/2
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
109700 get_qr(qr_HARDCODED_LITEM_LTMS)
2392 ? iClock
2393 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2394
2/4
✓ Branch 0 taken 109700 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 109700 times.
109700 if(itemid > -1 && checkbunny(itemid))
2395 109700 tile+=itemsbuf[itemid].ltm;
2396 109700 }
2397
2398
2/2
✓ Branch 0 taken 4671848 times.
✓ Branch 1 taken 1380741 times.
6052589 if(current_item(itype_key))
2399 {
2400 1380741 int32_t itemid =
2401
1/2
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
1380741 get_qr(qr_HARDCODED_LITEM_LTMS)
2402 ? iKey
2403 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2404
2/4
✓ Branch 0 taken 1380741 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1380741 times.
1380741 if(itemid > -1 && checkbunny(itemid))
2405 1380741 tile+=itemsbuf[itemid].ltm;
2406 1380741 }
2407
2408
2/2
✓ Branch 0 taken 5785486 times.
✓ Branch 1 taken 267103 times.
6052589 if(current_item(itype_lkey))
2409 {
2410 267103 int32_t itemid =
2411
2/2
✓ Branch 0 taken 266193 times.
✓ Branch 1 taken 910 times.
267103 get_qr(qr_HARDCODED_LITEM_LTMS)
2412 ? iLevelKey
2413 910 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2414
2/4
✓ Branch 0 taken 267103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 267103 times.
267103 if(itemid > -1 && checkbunny(itemid))
2415 267103 tile+=itemsbuf[itemid].ltm;
2416 267103 }
2417
2418
2/2
✓ Branch 0 taken 1255772 times.
✓ Branch 1 taken 4796817 times.
6052589 if(current_item(itype_map))
2419 {
2420 4796817 int32_t itemid =
2421
2/2
✓ Branch 0 taken 4796031 times.
✓ Branch 1 taken 786 times.
4796817 get_qr(qr_HARDCODED_LITEM_LTMS)
2422 ? iMap
2423 786 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2424
2/4
✓ Branch 0 taken 4796817 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4796817 times.
4796817 if(itemid > -1 && checkbunny(itemid))
2425 4796817 tile+=itemsbuf[itemid].ltm;
2426 4796817 }
2427
2428
2/2
✓ Branch 0 taken 1233890 times.
✓ Branch 1 taken 4818699 times.
6052589 if(current_item(itype_compass))
2429 {
2430 4818699 int32_t itemid =
2431
2/2
✓ Branch 0 taken 4737640 times.
✓ Branch 1 taken 81059 times.
4818699 get_qr(qr_HARDCODED_LITEM_LTMS)
2432 ? iCompass
2433 81059 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2434
2/4
✓ Branch 0 taken 4818699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4818699 times.
4818699 if(itemid > -1 && checkbunny(itemid))
2435 4818699 tile+=itemsbuf[itemid].ltm;
2436 4818699 }
2437
2438
2/2
✓ Branch 0 taken 3422044 times.
✓ Branch 1 taken 2630545 times.
6052589 if(current_item(itype_bosskey))
2439 {
2440 2630545 int32_t itemid =
2441
1/2
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
2630545 get_qr(qr_HARDCODED_LITEM_LTMS)
2442 ? iBossKey
2443 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2444
2/4
✓ Branch 0 taken 2630545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2630545 times.
2630545 if(itemid > -1 && checkbunny(itemid))
2445 2630545 tile+=itemsbuf[itemid].ltm;
2446 2630545 }
2447
2448
2/2
✓ Branch 0 taken 2918613 times.
✓ Branch 1 taken 3133976 times.
6052589 if(current_item(itype_magiccontainer))
2449 {
2450 3133976 int32_t itemid =
2451
2/2
✓ Branch 0 taken 3040989 times.
✓ Branch 1 taken 92987 times.
3133976 get_qr(qr_HARDCODED_LITEM_LTMS)
2452 ? iMagicC
2453 92987 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2454
3/4
✓ Branch 0 taken 3133976 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1870 times.
✓ Branch 3 taken 3132106 times.
3133976 if(itemid > -1 && checkbunny(itemid))
2455 3132106 tile+=itemsbuf[itemid].ltm;
2456 3133976 }
2457
2458
2/2
✓ Branch 0 taken 1591955 times.
✓ Branch 1 taken 4460634 times.
6052589 if(current_item(itype_triforcepiece))
2459 {
2460 4460634 int32_t itemid =
2461
1/2
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
4460634 get_qr(qr_HARDCODED_LITEM_LTMS)
2462 ? iTriforce
2463 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2464
2/4
✓ Branch 0 taken 4460634 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4460634 times.
4460634 if(itemid > -1 && checkbunny(itemid))
2465 4460634 tile+=itemsbuf[itemid].ltm;
2466 4460634 }
2467
2468
2/2
✓ Branch 0 taken 6052589 times.
✓ Branch 1 taken 3098925568 times.
3104978157 for(int32_t i=0; i<itype_max; i++)
2469 {
2470
2/2
✓ Branch 0 taken 3042451456 times.
✓ Branch 1 taken 56474112 times.
3098925568 if(!get_qr(qr_HARDCODED_LITEM_LTMS))
2471 {
2472
2/2
✓ Branch 0 taken 1103010 times.
✓ Branch 1 taken 55371102 times.
56474112 switch(i)
2473 {
2474 case itype_bomb:
2475 case itype_sbomb:
2476 case itype_clock:
2477 case itype_key:
2478 case itype_lkey:
2479 case itype_map:
2480 case itype_compass:
2481 case itype_bosskey:
2482 case itype_magiccontainer:
2483 case itype_triforcepiece:
2484 1103010 continue; //already handled
2485 }
2486 55371102 }
2487 3097822558 int32_t itemid = current_item_id(i,false);
2488
2/2
✓ Branch 0 taken 3091769969 times.
✓ Branch 1 taken 6052589 times.
3097822558 if(i == itype_shield)
2489 6052589 itemid = getCurrentShield(false);
2490
2491
4/4
✓ Branch 0 taken 80854394 times.
✓ Branch 1 taken 3016968164 times.
✓ Branch 2 taken 100981 times.
✓ Branch 3 taken 80753413 times.
3097822558 if(itemid < 0 || !checkbunny(itemid))
2492 3017069145 continue;
2493
2494 80753413 itemdata const& itm = itemsbuf[itemid];
2495
2496
2/2
✓ Branch 0 taken 75338158 times.
✓ Branch 1 taken 5415255 times.
80753413 switch(itm.family)
2497 {
2498 case itype_shield:
2499
1/2
✓ Branch 0 taken 5415255 times.
✗ Branch 1 not taken.
5415255 if(itm.flags & ITEM_FLAG9) //active shield
2500 {
2501 if(!usingActiveShield(itemid))
2502 {
2503 tile+=itm.misc6; //'Inactive PTM'
2504 continue;
2505 }
2506 }
2507 5415255 break;
2508 }
2509
2510 80753413 tile+=itm.ltm;
2511 80753413 }
2512
2513 6052589 return tile;
2514 }
2515
2516 6052589 int32_t bunny_tile_mod()
2517 {
2518
2/2
✓ Branch 0 taken 1870 times.
✓ Branch 1 taken 6050719 times.
6052589 if(Hero.BunnyClock())
2519 {
2520 1870 return game->get_bunny_ltm();
2521 }
2522 6050719 return 0;
2523 6052589 }
2524
2525 // Hints are drawn on a separate layer to combo reveals.
2526 16332 void draw_lens_under(BITMAP *dest, bool layer)
2527 {
2528 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2529 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2530 //Lens flag 3: Don't show armos/chest/dive items
2531 //Lens flag 4: Show Raft Paths
2532 //Lens flag 5: Show Invisible Enemies
2533
4/4
✓ Branch 0 taken 456 times.
✓ Branch 1 taken 15876 times.
✓ Branch 2 taken 7938 times.
✓ Branch 3 taken 7938 times.
16332 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2534
2535 16332 int32_t strike_hint_table[11]=
2536 {
2537 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2538 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2539 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2540 };
2541
2542 // int32_t page = tmpscr->cpage;
2543 {
2544 16332 int32_t blink_rate=flash_reduction_enabled()?6:1;
2545 // int32_t temptimer=0;
2546 16332 int32_t tempitem, tempweapon=0;
2547 16332 strike_hint=strike_hint_table[strike_hint_counter];
2548
2549
2/2
✓ Branch 0 taken 15842 times.
✓ Branch 1 taken 490 times.
16332 if(strike_hint_timer>32)
2550 {
2551 490 strike_hint_timer=0;
2552 490 strike_hint_counter=((strike_hint_counter+1)%11);
2553 490 }
2554
2555 16332 ++strike_hint_timer;
2556
2557
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 16332 times.
2890764 for(int32_t i=0; i<176; i++)
2558 {
2559 2874432 int32_t x = (i & 15) << 4;
2560 2874432 int32_t y = (i & 0xF0) + playing_field_offset;
2561 2874432 int32_t tempitemx=-16, tempitemy=-16;
2562 2874432 int32_t tempweaponx=-16, tempweapony=-16;
2563
2564
2/2
✓ Branch 0 taken 5748864 times.
✓ Branch 1 taken 2874432 times.
8623296 for(int32_t iter=0; iter<2; ++iter)
2565 {
2566 5748864 int32_t checkflag=0;
2567
2568
2/2
✓ Branch 0 taken 2874432 times.
✓ Branch 1 taken 2874432 times.
5748864 if(iter==0)
2569 {
2570 2874432 checkflag=combobuf[tmpscr->data[i]].flag;
2571 2874432 }
2572 else
2573 {
2574 2874432 checkflag=tmpscr->sflag[i];
2575 }
2576
2577
2/2
✓ Branch 0 taken 5747766 times.
✓ Branch 1 taken 1098 times.
5748864 if(checkflag==mfSTRIKE)
2578 {
2579
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 906 times.
1098 if(!hints)
2580 {
2581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2582 906 }
2583 else
2584 {
2585 192 checkflag = strike_hint;
2586 }
2587 1098 }
2588
2589
20/36
✓ Branch 0 taken 5706470 times.
✓ Branch 1 taken 3148 times.
✓ Branch 2 taken 3618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2064 times.
✓ Branch 5 taken 28640 times.
✓ Branch 6 taken 2418 times.
✓ Branch 7 taken 504 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 814 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 33 times.
✓ Branch 15 taken 96 times.
✓ Branch 16 taken 24 times.
✓ Branch 17 taken 5 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 16 times.
✓ Branch 23 taken 7 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 16 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 17 times.
✓ Branch 32 taken 35 times.
✓ Branch 33 taken 17 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 906 times.
5748864 switch(checkflag)
2590 {
2591 case 0:
2592 case mfZELDA:
2593 case mfPUSHED:
2594 case mfENEMY0:
2595 case mfENEMY1:
2596 case mfENEMY2:
2597 case mfENEMY3:
2598 case mfENEMY4:
2599 case mfENEMY5:
2600 case mfENEMY6:
2601 case mfENEMY7:
2602 case mfENEMY8:
2603 case mfENEMY9:
2604 case mfSINGLE:
2605 case mfSINGLE16:
2606 case mfNOENEMY:
2607 case mfTRAP_H:
2608 case mfTRAP_V:
2609 case mfTRAP_4:
2610 case mfTRAP_LR:
2611 case mfTRAP_UD:
2612 case mfNOGROUNDENEMY:
2613 case mfNOBLOCKS:
2614 case mfSCRIPT1:
2615 case mfSCRIPT2:
2616 case mfSCRIPT3:
2617 case mfSCRIPT4:
2618 case mfSCRIPT5:
2619 case mfSCRIPT6:
2620 case mfSCRIPT7:
2621 case mfSCRIPT8:
2622 case mfSCRIPT9:
2623 case mfSCRIPT10:
2624 case mfSCRIPT11:
2625 case mfSCRIPT12:
2626 case mfSCRIPT13:
2627 case mfSCRIPT14:
2628 case mfSCRIPT15:
2629 case mfSCRIPT16:
2630 case mfSCRIPT17:
2631 case mfSCRIPT18:
2632 case mfSCRIPT19:
2633 case mfSCRIPT20:
2634 case mfPITHOLE:
2635 case mfPITFALLFLOOR:
2636 case mfLAVA:
2637 case mfICE:
2638 case mfICEDAMAGE:
2639 case mfDAMAGE1:
2640 case mfDAMAGE2:
2641 case mfDAMAGE4:
2642 case mfDAMAGE8:
2643 case mfDAMAGE16:
2644 case mfDAMAGE32:
2645 case mfFREEZEALL:
2646 case mfFREZEALLANSFFCS:
2647 case mfFREEZEFFCSOLY:
2648 case mfSCRITPTW1TRIG:
2649 case mfSCRITPTW2TRIG:
2650 case mfSCRITPTW3TRIG:
2651 case mfSCRITPTW4TRIG:
2652 case mfSCRITPTW5TRIG:
2653 case mfSCRITPTW6TRIG:
2654 case mfSCRITPTW7TRIG:
2655 case mfSCRITPTW8TRIG:
2656 case mfSCRITPTW9TRIG:
2657 case mfSCRITPTW10TRIG:
2658 case mfTROWEL:
2659 case mfTROWELNEXT:
2660 case mfTROWELSPECIALITEM:
2661 case mfSLASHPOT:
2662 case mfLIFTPOT:
2663 case mfLIFTORSLASH:
2664 case mfLIFTROCK:
2665 case mfLIFTROCKHEAVY:
2666 case mfDROPITEM:
2667 case mfSPECIALITEM:
2668 case mfDROPKEY:
2669 case mfDROPLKEY:
2670 case mfDROPCOMPASS:
2671 case mfDROPMAP:
2672 case mfDROPBOSSKEY:
2673 case mfSPAWNNPC:
2674 case mfSWITCHHOOK:
2675 case mfSIDEVIEWLADDER:
2676 case mfSIDEVIEWPLATFORM:
2677 case mfNOENEMYSPAWN:
2678 case mfENEMYALL:
2679 case mfNOMIRROR:
2680 case mfUNSAFEGROUND:
2681 case mf168:
2682 case mf169:
2683 case mf170:
2684 case mf171:
2685 case mf172:
2686 case mf173:
2687 case mf174:
2688 case mf175:
2689 case mf176:
2690 case mf177:
2691 case mf178:
2692 case mf179:
2693 case mf180:
2694 case mf181:
2695 case mf182:
2696 case mf183:
2697 case mf184:
2698 case mf185:
2699 case mf186:
2700 case mf187:
2701 case mf188:
2702 case mf189:
2703 case mf190:
2704 case mf191:
2705 case mf192:
2706 case mf193:
2707 case mf194:
2708 case mf195:
2709 case mf196:
2710 case mf197:
2711 case mf198:
2712 case mf199:
2713 case mf200:
2714 case mf201:
2715 case mf202:
2716 case mf203:
2717 case mf204:
2718 case mf205:
2719 case mf206:
2720 case mf207:
2721 case mf208:
2722 case mf209:
2723 case mf210:
2724 case mf211:
2725 case mf212:
2726 case mf213:
2727 case mf214:
2728 case mf215:
2729 case mf216:
2730 case mf217:
2731 case mf218:
2732 case mf219:
2733 case mf220:
2734 case mf221:
2735 case mf222:
2736 case mf223:
2737 case mf224:
2738 case mf225:
2739 case mf226:
2740 case mf227:
2741 case mf228:
2742 case mf229:
2743 case mf230:
2744 case mf231:
2745 case mf232:
2746 case mf233:
2747 case mf234:
2748 case mf235:
2749 case mf236:
2750 case mf237:
2751 case mf238:
2752 case mf239:
2753 case mf240:
2754 case mf241:
2755 case mf242:
2756 case mf243:
2757 case mf244:
2758 case mf245:
2759 case mf246:
2760 case mf247:
2761 case mf248:
2762 case mf249:
2763 case mf250:
2764 case mf251:
2765 case mf252:
2766 case mf253:
2767 case mf254:
2768 case mfEXTENDED:
2769 5706470 break;
2770
2771 case mfPUSHUD:
2772 case mfPUSHLR:
2773 case mfPUSH4:
2774 case mfPUSHU:
2775 case mfPUSHD:
2776 case mfPUSHL:
2777 case mfPUSHR:
2778 case mfPUSHUDNS:
2779 case mfPUSHLRNS:
2780 case mfPUSH4NS:
2781 case mfPUSHUNS:
2782 case mfPUSHDNS:
2783 case mfPUSHLNS:
2784 case mfPUSHRNS:
2785 case mfPUSHUDINS:
2786 case mfPUSHLRINS:
2787 case mfPUSH4INS:
2788 case mfPUSHUINS:
2789 case mfPUSHDINS:
2790 case mfPUSHLINS:
2791 case mfPUSHRINS:
2792
3/4
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 1319 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
3148 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2793
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1829 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1829 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2794 {
2795 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2796 }
2797
2798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3148 times.
3148 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2799
3/6
✓ Branch 0 taken 2438 times.
✓ Branch 1 taken 710 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 710 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2800 {
2801
2/2
✓ Branch 0 taken 1406 times.
✓ Branch 1 taken 1032 times.
2438 if(hints)
2802 {
2803
3/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 897 times.
1032 switch(combobuf[tmpscr->data[i]].type)
2804 {
2805 case cPUSH_HEAVY:
2806 case cPUSH_HW:
2807 72 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2808 72 tempitemx=x, tempitemy=y;
2809
2810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(tempitem>-1)
2811 72 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2812
2813 72 break;
2814
2815 case cPUSH_HEAVY2:
2816 case cPUSH_HW2:
2817 63 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2818 63 tempitemx=x, tempitemy=y;
2819
2820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(tempitem>-1)
2821 63 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2822
2823 63 break;
2824 }
2825 1032 }
2826 2438 }
2827
2828 3148 break;
2829
2830 case mfWHISTLE:
2831
1/2
✓ Branch 0 taken 2418 times.
✗ Branch 1 not taken.
2418 if(hints)
2832 {
2833 tempitem=getItemID(itemsbuf,itype_whistle,1);
2834
2835 if(tempitem<0) break;
2836
2837 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2838 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2839 {
2840 tempitemx=x;
2841 tempitemy=y;
2842 }
2843
2844 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2845 }
2846
2847 2418 break;
2848
2849 //Why is this here?
2850 case mfFAIRY:
2851 case mfMAGICFAIRY:
2852 case mfALLFAIRY:
2853 if(hints)
2854 {
2855 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2856
2857 if(tempitem < 0) break;
2858
2859 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2860 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2861 {
2862 tempitemx=x;
2863 tempitemy=y;
2864 }
2865
2866 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2867 }
2868
2869 break;
2870
2871 case mfANYFIRE:
2872
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 252 times.
504 if(!hints)
2873 {
2874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2875 252 }
2876 else
2877 {
2878 252 tempitem=getItemID(itemsbuf,itype_candle,1);
2879
2880
1/2
✓ Branch 0 taken 252 times.
✗ Branch 1 not taken.
252 if(tempitem<0) break;
2881
2882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2883
3/6
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
252 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2884 {
2885 189 tempitemx=x;
2886 189 tempitemy=y;
2887 189 }
2888
2889 252 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2890 }
2891
2892 504 break;
2893
2894 case mfSTRONGFIRE:
2895 if(!hints)
2896 {
2897 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2898 }
2899 else
2900 {
2901 tempitem=getItemID(itemsbuf,itype_candle,2);
2902
2903 if(tempitem<0) break;
2904
2905 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2906 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2907 {
2908 tempitemx=x;
2909 tempitemy=y;
2910 }
2911
2912 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2913 }
2914
2915 break;
2916
2917 case mfMAGICFIRE:
2918 if(!hints)
2919 {
2920 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2921 }
2922 else
2923 {
2924 tempitem=getItemID(itemsbuf,itype_wand,1);
2925
2926 if(tempitem<0) break;
2927
2928 tempweapon=wFire;
2929
2930 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2931 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2932 {
2933 tempitemx=x;
2934 tempitemy=y;
2935 }
2936 else
2937 {
2938 tempweaponx=x;
2939 tempweapony=y;
2940 }
2941
2942 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2943 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2944 }
2945
2946 break;
2947
2948 case mfDIVINEFIRE:
2949 if(!hints)
2950 {
2951 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDIVINEFIRE],tmpscr->secretcset[sDIVINEFIRE]);
2952 }
2953 else
2954 {
2955 tempitem=getItemID(itemsbuf,itype_divinefire,1);
2956
2957 if(tempitem<0) break;
2958
2959 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2960 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2961 {
2962 tempitemx=x;
2963 tempitemy=y;
2964 }
2965
2966 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2967 }
2968
2969 break;
2970
2971 case mfARROW:
2972
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 732 times.
814 if(!hints)
2973 {
2974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 732 times.
732 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2975 732 }
2976 else
2977 {
2978 82 tempitem=getItemID(itemsbuf,itype_arrow,1);
2979
2980
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(tempitem<0) break;
2981
2982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2983
3/6
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
82 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2984 {
2985 61 tempitemx=x;
2986 61 tempitemy=y;
2987 61 }
2988
2989 82 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2990 }
2991
2992 814 break;
2993
2994 case mfSARROW:
2995 if(!hints)
2996 {
2997 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2998 }
2999 else
3000 {
3001 tempitem=getItemID(itemsbuf,itype_arrow,2);
3002
3003 if(tempitem<0) break;
3004
3005 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3006 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3007 {
3008 tempitemx=x;
3009 tempitemy=y;
3010 }
3011
3012 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3013 }
3014
3015 break;
3016
3017 case mfGARROW:
3018 if(!hints)
3019 {
3020 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
3021 }
3022 else
3023 {
3024 tempitem=getItemID(itemsbuf,itype_arrow,3);
3025
3026 if(tempitem<0) break;
3027
3028 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3029 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3030 {
3031 tempitemx=x;
3032 tempitemy=y;
3033 }
3034
3035 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3036 }
3037
3038 break;
3039
3040 case mfBOMB:
3041
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!hints)
3042 {
3043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
3044 16 }
3045 else
3046 {
3047 //tempitem=getItemID(itemsbuf,itype_bomb,1);
3048 17 tempweapon = wLitBomb;
3049
3050 //if (tempitem<0) break;
3051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3052
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3053 {
3054 12 tempweaponx=x;
3055 12 tempweapony=y;
3056 12 }
3057
3058 17 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3059 }
3060
3061 33 break;
3062
3063 case mfSBOMB:
3064
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 48 times.
96 if(!hints)
3065 {
3066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3067 48 }
3068 else
3069 {
3070 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3071 //if (tempitem<0) break;
3072 48 tempweapon = wLitSBomb;
3073
3074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3075
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3076 {
3077 36 tempweaponx=x;
3078 36 tempweapony=y;
3079 36 }
3080
3081 48 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3082 }
3083
3084 96 break;
3085
3086 case mfARMOS_SECRET:
3087
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
24 if(!hints)
3088 {
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3090 12 }
3091 24 break;
3092
3093 case mfBRANG:
3094
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!hints)
3095 {
3096 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3097 }
3098 else
3099 {
3100 5 tempitem=getItemID(itemsbuf,itype_brang,1);
3101
3102
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(tempitem<0) break;
3103
3104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3105
3/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3106 {
3107 4 tempitemx=x;
3108 4 tempitemy=y;
3109 4 }
3110
3111 5 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3112 }
3113
3114 5 break;
3115
3116 case mfMBRANG:
3117 if(!hints)
3118 {
3119 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3120 }
3121 else
3122 {
3123 tempitem=getItemID(itemsbuf,itype_brang,2);
3124
3125 if(tempitem<0) break;
3126
3127 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3128 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3129 {
3130 tempitemx=x;
3131 tempitemy=y;
3132 }
3133
3134 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3135 }
3136
3137 break;
3138
3139 case mfFBRANG:
3140 if(!hints)
3141 {
3142 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3143 }
3144 else
3145 {
3146 tempitem=getItemID(itemsbuf,itype_brang,3);
3147
3148 if(tempitem<0) break;
3149
3150 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3151 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3152 {
3153 tempitemx=x;
3154 tempitemy=y;
3155 }
3156
3157 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3158 }
3159
3160 break;
3161
3162 case mfWANDMAGIC:
3163 if(!hints)
3164 {
3165 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3166 }
3167 else
3168 {
3169 tempitem=getItemID(itemsbuf,itype_wand,1);
3170
3171 if(tempitem<0) break;
3172
3173 tempweapon=itemsbuf[tempitem].wpn3;
3174
3175 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3176 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3177 {
3178 tempitemx=x;
3179 tempitemy=y;
3180 }
3181 else
3182 {
3183 tempweaponx=x;
3184 tempweapony=y;
3185 --lens_hint_weapon[wMagic][4];
3186
3187 if(lens_hint_weapon[wMagic][4]<-8)
3188 {
3189 lens_hint_weapon[wMagic][4]=8;
3190 }
3191 }
3192
3193 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3194 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3195 }
3196
3197 break;
3198
3199 case mfREFMAGIC:
3200
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3201 {
3202 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3203 }
3204 else
3205 {
3206 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3207
3208
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3209
3210 16 tempweapon=ewMagic;
3211
3212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3213
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3214 {
3215 13 tempitemx=x;
3216 13 tempitemy=y;
3217 13 }
3218 else
3219 {
3220 3 tempweaponx=x;
3221 3 tempweapony=y;
3222
3223
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
3 if(lens_hint_weapon[ewMagic][2]==up)
3224 {
3225 1 --lens_hint_weapon[ewMagic][4];
3226 1 }
3227 else
3228 {
3229 2 ++lens_hint_weapon[ewMagic][4];
3230 }
3231
3232
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(lens_hint_weapon[ewMagic][4]>8)
3233 {
3234 lens_hint_weapon[ewMagic][2]=up;
3235 }
3236
3237
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(lens_hint_weapon[ewMagic][4]<=0)
3238 {
3239 2 lens_hint_weapon[ewMagic][2]=down;
3240 2 }
3241 }
3242
3243 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3244 16 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3245 }
3246
3247 16 break;
3248
3249 case mfREFFIREBALL:
3250
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3251 {
3252 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3253 }
3254 else
3255 {
3256 16 tempitem=getItemID(itemsbuf,itype_shield,3);
3257
3258
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3259
3260 16 tempweapon=ewFireball;
3261
3262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3263
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3264 {
3265 12 tempitemx=x;
3266 12 tempitemy=y;
3267 12 tempweaponx=x;
3268 12 tempweapony=y;
3269 12 ++lens_hint_weapon[ewFireball][3];
3270
3271
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 1 times.
12 if(lens_hint_weapon[ewFireball][3]>8)
3272 {
3273 1 lens_hint_weapon[ewFireball][3]=-8;
3274 1 lens_hint_weapon[ewFireball][4]=8;
3275 1 }
3276
3277
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 4 times.
12 if(lens_hint_weapon[ewFireball][3]>0)
3278 {
3279 8 ++lens_hint_weapon[ewFireball][4];
3280 8 }
3281 else
3282 {
3283 4 --lens_hint_weapon[ewFireball][4];
3284 }
3285 12 }
3286
3287 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3288 16 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3289 }
3290
3291 16 break;
3292
3293 case mfSWORD:
3294
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!hints)
3295 {
3296 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3297 }
3298 else
3299 {
3300 7 tempitem=getItemID(itemsbuf,itype_sword,1);
3301
3302
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(tempitem<0) break;
3303
3304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3305
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3306 {
3307 5 tempitemx=x;
3308 5 tempitemy=y;
3309 5 }
3310
3311 7 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3312 }
3313
3314 7 break;
3315
3316 case mfWSWORD:
3317 if(!hints)
3318 {
3319 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3320 }
3321 else
3322 {
3323 tempitem=getItemID(itemsbuf,itype_sword,2);
3324
3325 if(tempitem<0) break;
3326
3327 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3328 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3329 {
3330 tempitemx=x;
3331 tempitemy=y;
3332 }
3333
3334 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3335 }
3336
3337 break;
3338
3339 case mfMSWORD:
3340 if(!hints)
3341 {
3342 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3343 }
3344 else
3345 {
3346 tempitem=getItemID(itemsbuf,itype_sword,3);
3347
3348 if(tempitem<0) break;
3349
3350 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3351 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3352 {
3353 tempitemx=x;
3354 tempitemy=y;
3355 }
3356
3357 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3358 }
3359
3360 break;
3361
3362 case mfXSWORD:
3363 if(!hints)
3364 {
3365 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3366 }
3367 else
3368 {
3369 tempitem=getItemID(itemsbuf,itype_sword,4);
3370
3371 if(tempitem<0) break;
3372
3373 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3374 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3375 {
3376 tempitemx=x;
3377 tempitemy=y;
3378 }
3379
3380 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3381 }
3382
3383 break;
3384
3385 case mfSWORDBEAM:
3386
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!hints)
3387 {
3388 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3389 }
3390 else
3391 {
3392 16 tempitem=getItemID(itemsbuf,itype_sword,1);
3393
3394
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(tempitem<0) break;
3395
3396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3397
3/6
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3398 {
3399 11 tempitemx=x;
3400 11 tempitemy=y;
3401 11 }
3402
3403 16 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3404 }
3405
3406 16 break;
3407
3408 case mfWSWORDBEAM:
3409 if(!hints)
3410 {
3411 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3412 }
3413 else
3414 {
3415 tempitem=getItemID(itemsbuf,itype_sword,2);
3416
3417 if(tempitem<0) break;
3418
3419 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3420 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3421 {
3422 tempitemx=x;
3423 tempitemy=y;
3424 }
3425
3426 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3427 }
3428
3429 break;
3430
3431 case mfMSWORDBEAM:
3432 if(!hints)
3433 {
3434 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3435 }
3436 else
3437 {
3438 tempitem=getItemID(itemsbuf,itype_sword,3);
3439
3440 if(tempitem<0) break;
3441
3442 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3443 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3444 {
3445 tempitemx=x;
3446 tempitemy=y;
3447 }
3448
3449 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3450 }
3451
3452 break;
3453
3454 case mfXSWORDBEAM:
3455 if(!hints)
3456 {
3457 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3458 }
3459 else
3460 {
3461 tempitem=getItemID(itemsbuf,itype_sword,4);
3462
3463 if(tempitem<0) break;
3464
3465 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3466 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3467 {
3468 tempitemx=x;
3469 tempitemy=y;
3470 }
3471
3472 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3473 }
3474
3475 break;
3476
3477 case mfHOOKSHOT:
3478
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3479 {
3480 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3481 }
3482 else
3483 {
3484 17 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3485
3486
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3487
3488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3489
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3490 {
3491 12 tempitemx=x;
3492 12 tempitemy=y;
3493 12 }
3494
3495 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3496 }
3497
3498 17 break;
3499
3500 case mfWAND:
3501
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(!hints)
3502 {
3503 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3504 }
3505 else
3506 {
3507 35 tempitem=getItemID(itemsbuf,itype_wand,1);
3508
3509
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(tempitem<0) break;
3510
3511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3512
3/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3513 {
3514 28 tempitemx=x;
3515 28 tempitemy=y;
3516 28 }
3517
3518 35 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3519 }
3520
3521 35 break;
3522
3523 case mfHAMMER:
3524
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(!hints)
3525 {
3526 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3527 }
3528 else
3529 {
3530 17 tempitem=getItemID(itemsbuf,itype_hammer,1);
3531
3532
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(tempitem<0) break;
3533
3534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3535
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3536 {
3537 13 tempitemx=x;
3538 13 tempitemy=y;
3539 13 }
3540
3541 17 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3542 }
3543
3544 17 break;
3545
3546 case mfARMOS_ITEM:
3547 case mfDIVE_ITEM:
3548
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2064 times.
2064 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3549 {
3550 2064 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3551 2064 }
3552 2064 break;
3553
3554 case 16:
3555 case 17:
3556 case 18:
3557 case 19:
3558 case 20:
3559 case 21:
3560 case 22:
3561 case 23:
3562 case 24:
3563 case 25:
3564 case 26:
3565 case 27:
3566 case 28:
3567 case 29:
3568 case 30:
3569 case 31:
3570
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 2610 times.
3618 if(!hints)
3571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2610 times.
5220 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3572 2610 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3573
3574 3618 break;
3575 case mfSECRETSNEXT:
3576 if(!hints)
3577 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3578 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3579
3580 break;
3581
3582 case mfSTRIKE:
3583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3584 {
3585 906 goto special;
3586 }
3587 else
3588 {
3589 break;
3590 }
3591
3592 28640 default: goto special;
3593
3594 special:
3595
8/8
✓ Branch 0 taken 14677 times.
✓ Branch 1 taken 14869 times.
✓ Branch 2 taken 473 times.
✓ Branch 3 taken 14204 times.
✓ Branch 4 taken 441 times.
✓ Branch 5 taken 32 times.
✓ Branch 6 taken 6108 times.
✓ Branch 7 taken 8128 times.
29546 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3596 {
3597
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6549 times.
✓ Branch 2 taken 4913 times.
✓ Branch 3 taken 1636 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1636 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6549 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3598 {
3599 4913 rectfill(dest,x,y,x+15,y+15,WHITE);
3600 4913 }
3601 6549 }
3602
3603 29546 break;
3604 }
3605 5748864 }
3606 2874432 }
3607
3608
2/2
✓ Branch 0 taken 8166 times.
✓ Branch 1 taken 8166 times.
16332 if(layer)
3609 {
3610
2/2
✓ Branch 0 taken 7978 times.
✓ Branch 1 taken 188 times.
8166 if(tmpscr->door[0]==dWALK)
3611 188 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3612
3613
2/2
✓ Branch 0 taken 7969 times.
✓ Branch 1 taken 197 times.
8166 if(tmpscr->door[1]==dWALK)
3614 197 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3615
3616
2/2
✓ Branch 0 taken 8014 times.
✓ Branch 1 taken 152 times.
8166 if(tmpscr->door[2]==dWALK)
3617 152 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3618
3619
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 226 times.
8166 if(tmpscr->door[3]==dWALK)
3620 226 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3621
3622
2/2
✓ Branch 0 taken 8123 times.
✓ Branch 1 taken 43 times.
8166 if(tmpscr->door[0]==dBOMB)
3623 {
3624 43 showbombeddoor(dest, 0);
3625 43 }
3626
3627
2/2
✓ Branch 0 taken 8127 times.
✓ Branch 1 taken 39 times.
8166 if(tmpscr->door[1]==dBOMB)
3628 {
3629 39 showbombeddoor(dest, 1);
3630 39 }
3631
3632
1/2
✓ Branch 0 taken 8166 times.
✗ Branch 1 not taken.
8166 if(tmpscr->door[2]==dBOMB)
3633 {
3634 showbombeddoor(dest, 2);
3635 }
3636
3637
2/2
✓ Branch 0 taken 8129 times.
✓ Branch 1 taken 37 times.
8166 if(tmpscr->door[3]==dBOMB)
3638 {
3639 37 showbombeddoor(dest, 3);
3640 37 }
3641 8166 }
3642
3643
2/2
✓ Branch 0 taken 14298 times.
✓ Branch 1 taken 2034 times.
16332 if(tmpscr->stairx + tmpscr->stairy)
3644 {
3645
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1123 times.
2034 if(!hints)
3646 {
3647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1123 times.
1123 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3648 1123 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3649 1123 }
3650 else
3651 {
3652
2/2
✓ Branch 0 taken 863 times.
✓ Branch 1 taken 48 times.
911 if(tmpscr->flags&fWHISTLE)
3653 {
3654 48 tempitem=getItemID(itemsbuf,itype_whistle,1);
3655 48 int32_t tempitemx=-16;
3656 48 int32_t tempitemy=-16;
3657
3658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3659
3/6
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3660 {
3661 24 tempitemx=tmpscr->stairx;
3662 24 tempitemy=tmpscr->stairy+playing_field_offset;
3663 24 }
3664
3665 48 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3666 48 }
3667 }
3668 2034 }
3669 }
3670 16332 }
3671
3672 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3673
3674 7997 void draw_lens_over()
3675 {
3676 // Oh, what the heck.
3677 static BITMAP *lens_scr = NULL;
3678 static int32_t last_width = -1;
3679 7997 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3680
3681 // Only redraw the circle if the size has changed
3682
2/2
✓ Branch 0 taken 7987 times.
✓ Branch 1 taken 10 times.
7997 if(width != last_width)
3683 {
3684
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lens_scr == NULL)
3685 {
3686 10 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3687 10 }
3688
3689 10 clear_to_color(lens_scr, BLACK);
3690 10 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3691 10 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3692 10 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3693 10 last_width=width;
3694 10 }
3695
3696 7997 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3697 7997 do_primitives(framebuf, SPLAYER_LENS_OVER, tmpscr, 0, playing_field_offset);
3698 7997 }
3699
3700 //----------------------------------------------------------------
3701
3702 31111 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3703 {
3704 //recreating a big bitmap every frame is highly sluggish.
3705
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 31108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
31111 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3706 31111 clear_to_color(wavebuf, BLACK);
3707 31111 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3708
3709 int32_t ofs;
3710 // int32_t amplitude=8;
3711 // int32_t wavelength=4;
3712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31111 times.
31111 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3713
3/6
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3714 31111 int32_t amp2=168;
3715
2/4
✓ Branch 0 taken 31111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31111 times.
31111 if(flash_reduction_enabled() && !get_qr(qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3716 31111 int32_t i=frame%amp2;
3717
3718
2/2
✓ Branch 0 taken 5226648 times.
✓ Branch 1 taken 31111 times.
5257759 for(int32_t j=0; j<168; j++)
3719 {
3720
3/4
✓ Branch 0 taken 2613324 times.
✓ Branch 1 taken 2613324 times.
✓ Branch 2 taken 2613324 times.
✗ Branch 3 not taken.
5226648 if(j&1 && interpol)
3721 {
3722 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3723 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3724 }
3725 else
3726 {
3727 5226648 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3728 }
3729
3730
1/2
✓ Branch 0 taken 5226648 times.
✗ Branch 1 not taken.
5226648 if(ofs)
3731 {
3732
2/2
✓ Branch 0 taken 1338021888 times.
✓ Branch 1 taken 5226648 times.
1343248536 for(int32_t k=0; k<256; k++)
3733 {
3734 1338021888 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3735 1338021888 }
3736 5226648 }
3737 5226648 }
3738 31111 }
3739
3740 4848 void draw_fuzzy(int32_t fuzz)
3741 // draws from right half of scrollbuf to framebuf
3742 {
3743 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3744 byte *start, *si, *di;
3745
3746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4848 times.
4848 if(fuzz<1)
3747 fuzz = 1;
3748
3749 4848 xstep = 128%fuzz;
3750
3751
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 3838 times.
4848 if(xstep > 0)
3752 3838 xstep = fuzz-xstep;
3753
3754 4848 ystep = 112%fuzz;
3755
3756
2/2
✓ Branch 0 taken 1414 times.
✓ Branch 1 taken 3434 times.
4848 if(ystep > 0)
3757 3434 ystep = fuzz-ystep;
3758
3759 4848 firsty = 1;
3760
3761
2/2
✓ Branch 0 taken 4848 times.
✓ Branch 1 taken 174932 times.
179780 for(y=0; y<224;)
3762 {
3763 174932 start = &(scrollbuf->line[y][256]);
3764
3765
4/4
✓ Branch 0 taken 172508 times.
✓ Branch 1 taken 1088376 times.
✓ Branch 2 taken 1085952 times.
✓ Branch 3 taken 174932 times.
1260884 for(dy=0; dy<ystep && dy+y<224; dy++)
3766 {
3767 1085952 si = start;
3768 1085952 di = &(framebuf->line[y+dy][0]);
3769 1085952 i = xstep;
3770 1085952 firstx = 1;
3771
3772
2/2
✓ Branch 0 taken 278003712 times.
✓ Branch 1 taken 1085952 times.
279089664 for(dx=0; dx<256; dx++)
3773 {
3774 278003712 *(di++) = *si;
3775
3776
2/2
✓ Branch 0 taken 234248896 times.
✓ Branch 1 taken 43754816 times.
278003712 if(++i >= fuzz)
3777 {
3778
2/2
✓ Branch 0 taken 42668864 times.
✓ Branch 1 taken 1085952 times.
43754816 if(!firstx)
3779 42668864 si += fuzz;
3780 else
3781 {
3782 1085952 si += fuzz-xstep;
3783 1085952 firstx = 0;
3784 }
3785
3786 43754816 i = 0;
3787 43754816 }
3788 278003712 }
3789 1085952 }
3790
3791
2/2
✓ Branch 0 taken 170084 times.
✓ Branch 1 taken 4848 times.
174932 if(!firsty)
3792 170084 y += fuzz;
3793 else
3794 {
3795 4848 y += ystep;
3796 4848 ystep = fuzz;
3797 4848 firsty = 0;
3798 }
3799 }
3800 4848 }
3801
3802 9286026 void updatescr(bool allowwavy)
3803 {
3804
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
9286026 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3805
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285912 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
9286026 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3806
3807
2/2
✓ Branch 0 taken 9259261 times.
✓ Branch 1 taken 26765 times.
9286026 if(toogam)
3808 {
3809 26765 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3810 26765 }
3811
3812
1/2
✓ Branch 0 taken 9286026 times.
✗ Branch 1 not taken.
9286026 if(Showpal)
3813 dump_pal(framebuf);
3814
3815
2/2
✓ Branch 0 taken 8984794 times.
✓ Branch 1 taken 301232 times.
9286026 if(!Playing)
3816 301232 black_opening_count=0;
3817
3818
2/2
✓ Branch 0 taken 9212832 times.
✓ Branch 1 taken 73194 times.
9286026 if(black_opening_count<0) //shape is opening up
3819 {
3820 73194 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3821
3822
2/4
✓ Branch 0 taken 73194 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73194 times.
73194 if(Advance||(!Paused))
3823 {
3824 73194 ++black_opening_count;
3825 73194 }
3826 73194 }
3827
2/2
✓ Branch 0 taken 9186696 times.
✓ Branch 1 taken 26136 times.
9212832 else if(black_opening_count>0) //shape is closing
3828 {
3829 26136 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3830
3831
2/4
✓ Branch 0 taken 26136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26136 times.
26136 if(Advance||(!Paused))
3832 {
3833 26136 --black_opening_count;
3834 26136 }
3835 26136 }
3836
3837
3/4
✓ Branch 0 taken 9188201 times.
✓ Branch 1 taken 97825 times.
✓ Branch 2 taken 9188201 times.
✗ Branch 3 not taken.
9286026 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3838 {
3839 black_opening_shape = bosCIRCLE;
3840 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3841 refreshTints();
3842 refreshpal=true;
3843 }
3844
3845
2/2
✓ Branch 0 taken 9031827 times.
✓ Branch 1 taken 254199 times.
9286026 if(refreshpal)
3846 {
3847 254199 refreshpal=false;
3848 254199 RAMpal[253] = _RGB(0,0,0);
3849 254199 RAMpal[254] = _RGB(63,63,63);
3850 254199 hw_palette = &RAMpal;
3851 254199 update_hw_pal = true;
3852
3853 254199 create_rgb_table(&rgb_table, RAMpal, NULL);
3854 254199 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3855 254199 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3856
3857
2/2
✓ Branch 0 taken 65074944 times.
✓ Branch 1 taken 254199 times.
65329143 for(int32_t q=0; q<PAL_SIZE; q++)
3858 {
3859 65074944 trans_table2.data[0][q] = q;
3860 65074944 trans_table2.data[q][q] = q;
3861 65074944 }
3862 254199 }
3863
3864 9286026 bool clearwavy = (wavy <= 0);
3865
3866
2/2
✓ Branch 0 taken 7655 times.
✓ Branch 1 taken 9278371 times.
9286026 if(wavy <= 0)
3867 {
3868 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3869 9278371 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3870 9278371 }
3871
3872 9286026 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3873
3874
6/6
✓ Branch 0 taken 31361 times.
✓ Branch 1 taken 9254665 times.
✓ Branch 2 taken 31239 times.
✓ Branch 3 taken 122 times.
✓ Branch 4 taken 128 times.
✓ Branch 5 taken 31111 times.
9286026 if(wavy && Playing && allowwavy)
3875 {
3876 31111 draw_wavy(framebuf, wavybuf, wavy,false);
3877 31111 }
3878
3879
2/2
✓ Branch 0 taken 9278371 times.
✓ Branch 1 taken 7655 times.
9286026 if(clearwavy)
3880 9278371 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3881
2/4
✓ Branch 0 taken 7655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7655 times.
7655 else if(Playing && !Paused)
3882 7655 wavy--; // Wavy was set by a script. Decrement it.
3883
3884
5/6
✓ Branch 0 taken 8984794 times.
✓ Branch 1 taken 301232 times.
✓ Branch 2 taken 259574 times.
✓ Branch 3 taken 8725220 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 259574 times.
9286026 if(Playing && msgpos && !screenscrolling)
3885 {
3886
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_bg_display_buf->clip))
3887 259574 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3888
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_portrait_display_buf->clip))
3889 259574 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3890
1/2
✓ Branch 0 taken 259574 times.
✗ Branch 1 not taken.
259574 if(!(msg_txt_display_buf->clip))
3891 259574 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3892 259574 }
3893
3894 /*
3895 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3896 {
3897 BITMAP* subBmp = 0;
3898 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3899 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3900 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3901 destroy_bitmap(subBmp);
3902 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3903 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3904 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3905 }
3906 */
3907
3908
2/2
✓ Branch 0 taken 9244969 times.
✓ Branch 1 taken 41057 times.
9286026 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3909
3910
2/2
✓ Branch 0 taken 9249594 times.
✓ Branch 1 taken 36432 times.
9286026 if(nosubscr)
3911 {
3912 36432 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3913 36432 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3914 36432 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3915 36432 }
3916
3917 //TODO: Optimize blit 'overcalls' -Gleeok
3918
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9249594 times.
9286026 BITMAP *source = nosubscr ? panorama : wavybuf;
3919 9286026 blit(source,framebuf,0,0,0,0,256,224);
3920
3921 9286026 update_hw_screen();
3922 9286026 }
3923
3924 //----------------------------------------------------------------
3925
3926 static PALETTE syspal;
3927 int32_t onGUISnapshot()
3928 {
3929 char buf[200];
3930 int32_t num=0;
3931 bool realpal=(CHECK_CTRL_CMD);
3932 do
3933 {
3934 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3935 }
3936 while(num<99999 && exists(buf));
3937
3938 BITMAP *b = create_bitmap_ex(8,resx,resy);
3939
3940 if(b)
3941 {
3942 blit(screen,b,0,0,0,0,resx,resy);
3943 save_bitmap(buf,screen,RAMpal);
3944 destroy_bitmap(b);
3945 }
3946
3947 return D_O_K;
3948 }
3949
3950 int32_t onNonGUISnapshot()
3951 {
3952 PALETTE temppal;
3953 get_palette(temppal);
3954 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3955
3956 char buf[200];
3957 int32_t num=0;
3958
3959 do
3960 {
3961 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3962 }
3963 while(num<99999 && exists(buf));
3964
3965 if (tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3966 {
3967 BITMAP *b = create_bitmap_ex(8,256,168);
3968 clear_to_color(b,0);
3969 blit(framebuf,b,0,passive_subscreen_height/2,0,0,256,168);
3970 save_bitmap(buf,b,realpal?temppal:RAMpal);
3971 destroy_bitmap(b);
3972 }
3973 else
3974 {
3975 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3976 }
3977
3978 return D_O_K;
3979 }
3980
3981 int32_t onSnapshot()
3982 {
3983 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3984 {
3985 onGUISnapshot();
3986 }
3987 else
3988 {
3989 onNonGUISnapshot();
3990 }
3991
3992 return D_O_K;
3993 }
3994
3995 int32_t onSaveMapPic()
3996 {
3997 int32_t mapres2 = 0;
3998 char buf[200];
3999 int32_t num=0;
4000 mapscr tmpscr_b[2];
4001 mapscr tmpscr_c[6];
4002 BITMAP* _screen_draw_buffer = NULL;
4003 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4004 set_clip_state(_screen_draw_buffer,1);
4005
4006 for(int32_t i=0; i<6; ++i)
4007 {
4008 tmpscr_c[i] = tmpscr2[i];
4009 tmpscr2[i].zero_memory();
4010
4011 if(i>=2)
4012 {
4013 continue;
4014 }
4015
4016 tmpscr_b[i] = tmpscr[i];
4017 tmpscr[i].zero_memory();
4018 }
4019
4020 do
4021 {
4022 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4023 }
4024 while(num<99999 && exists(buf));
4025
4026 BITMAP* mappic = NULL;
4027
4028
4029 bool done=false, redraw=true;
4030
4031 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4032
4033 if(!mappic)
4034 {
4035 enter_sys_pal();
4036 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
4037 exit_sys_pal();
4038 return D_O_K;;
4039 }
4040
4041 // draw the map
4042 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4043
4044 for(int32_t y=0; y<8; y++)
4045 {
4046 for(int32_t x=0; x<16; x++)
4047 {
4048 if(!displayOnMap(x, y))
4049 {
4050 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4051 }
4052 else
4053 {
4054 int32_t s = (y<<4) + x;
4055 loadscr2(1,s,-1);
4056
4057 for(int32_t i=0; i<6; i++)
4058 {
4059 if(tmpscr[1].layermap[i]<=0)
4060 continue;
4061
4062 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4063 }
4064
4065 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4068
4069 if(lenscheck(tmpscr+1,0)) putscr(_screen_draw_buffer,256,0,tmpscr+1);
4070 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4071
4072 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4073
4074 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4075 if(get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
4076 {
4077 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4078 if(get_qr(qr_PUSHBLOCK_LAYER_1_2))
4079 {
4080 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4081 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4082 }
4083 }
4084 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4085
4086 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4087
4088 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4089 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4090 if(get_qr(qr_OVERHEAD_COMBOS_L1_L2))
4091 {
4092 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4093 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4094 }
4095 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4096 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4097
4098 }
4099
4100 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4101 }
4102 }
4103
4104 for(int32_t i=0; i<6; ++i)
4105 {
4106 tmpscr2[i]=tmpscr_c[i];
4107
4108 if(i>=2)
4109 {
4110 continue;
4111 }
4112
4113 tmpscr[i]=tmpscr_b[i];
4114 }
4115
4116 save_bitmap(buf,mappic,RAMpal);
4117 destroy_bitmap(mappic);
4118 destroy_bitmap(_screen_draw_buffer);
4119 return D_O_K;
4120 }
4121
4122 14 void f_Quit(int32_t type)
4123 {
4124
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(type==qQUIT && !Playing)
4125 return;
4126
4127 14 bool from_menu = is_sys_pal;
4128
4129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4130 {
4131 14 music_pause();
4132 14 pause_all_sfx();
4133 14 sys_mouse();
4134 14 }
4135 14 enter_sys_pal();
4136 14 clear_keybuf();
4137
4138
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (replay_version_check(0, 10))
4139 13 replay_poll();
4140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if (replay_is_replaying())
4141 14 replay_peek_quit();
4142
4143
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (!replay_is_replaying())
4144 switch(type)
4145 {
4146 case qQUIT:
4147 onQuit();
4148 break;
4149
4150 case qRESET:
4151 onReset();
4152 break;
4153
4154 case qEXIT:
4155 onExit();
4156 break;
4157 }
4158
4159
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(Quit)
4160 {
4161 14 kill_sfx();
4162 14 music_stop();
4163 14 exit_sys_pal();
4164 14 update_hw_screen();
4165 14 }
4166 else
4167 {
4168 exit_sys_pal();
4169 if(!from_menu)
4170 {
4171 music_resume();
4172 resume_all_sfx();
4173 }
4174 }
4175
4176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!from_menu)
4177 14 game_mouse();
4178 14 eat_buttons();
4179
4180 14 zc_readrawkey(KEY_ESC);
4181
4182 14 zc_readrawkey(KEY_ENTER);
4183 14 }
4184
4185 //----------------------------------------------------------------
4186
4187 int32_t onNoWalls()
4188 {
4189 cheats_enqueue(Cheat::Walls);
4190 return D_O_K;
4191 }
4192
4193 int32_t onIgnoreSideview()
4194 {
4195 cheats_enqueue(Cheat::IgnoreSideView);
4196 return D_O_K;
4197 }
4198
4199 9285900 int32_t input_idle(bool checkmouse)
4200 {
4201 static int32_t mx, my, mz, mb;
4202
4203
4/6
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461351 times.
✓ Branch 3 taken 6824549 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2461351 times.
11747251 if(keypressed() || zc_key_pressed() ||
4204
4/8
✓ Branch 0 taken 2461351 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2461351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2461351 times.
✗ Branch 7 not taken.
2461351 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4205 {
4206 6824549 idle_count = 0;
4207
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6824549 times.
6824549 if(active_count < MAX_ACTIVE)
4209 {
4210 6824549 ++active_count;
4211 6824549 }
4212 6824549 }
4213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2461351 times.
2461351 else if(idle_count < MAX_IDLE)
4214 {
4215 2461351 ++idle_count;
4216 2461351 active_count = 0;
4217 2461351 }
4218
4219 9285900 mx = mouse_x;
4220 9285900 my = mouse_y;
4221 9285900 mz = mouse_z;
4222 9285900 mb = mouse_b;
4223
4224 9285900 return idle_count;
4225 }
4226
4227 int32_t onGoFast()
4228 {
4229 cheats_enqueue(Cheat::Fast);
4230 return D_O_K;
4231 }
4232
4233 int32_t onKillCheat()
4234 {
4235 cheats_enqueue(Cheat::Kill);
4236 return D_O_K;
4237 }
4238
4239 int32_t onSecretsCheat()
4240 {
4241 cheats_enqueue(Cheat::TrigSecrets);
4242 return D_O_K;
4243 }
4244 int32_t onSecretsCheatPerm()
4245 {
4246 cheats_enqueue(Cheat::TrigSecretsPerm);
4247 return D_O_K;
4248 }
4249
4250 int32_t onShowLayer0()
4251 {
4252 show_layer_0 = !show_layer_0;
4253 return D_O_K;
4254 }
4255 int32_t onShowLayer1()
4256 {
4257 show_layer_1 = !show_layer_1;
4258 return D_O_K;
4259 }
4260 int32_t onShowLayer2()
4261 {
4262 show_layer_2 = !show_layer_2;
4263 return D_O_K;
4264 }
4265 int32_t onShowLayer3()
4266 {
4267 show_layer_3 = !show_layer_3;
4268 return D_O_K;
4269 }
4270 int32_t onShowLayer4()
4271 {
4272 show_layer_4 = !show_layer_4;
4273 return D_O_K;
4274 }
4275 int32_t onShowLayer5()
4276 {
4277 show_layer_5 = !show_layer_5;
4278 return D_O_K;
4279 }
4280 int32_t onShowLayer6()
4281 {
4282 show_layer_6 = !show_layer_6;
4283 return D_O_K;
4284 }
4285 int32_t onShowLayerO()
4286 {
4287 show_layer_over=!show_layer_over;
4288 return D_O_K;
4289 }
4290 int32_t onShowLayerP()
4291 {
4292 show_layer_push=!show_layer_push;
4293 return D_O_K;
4294 }
4295 int32_t onShowLayerS()
4296 {
4297 show_sprites=!show_sprites;
4298 return D_O_K;
4299 }
4300 int32_t onShowLayerF()
4301 {
4302 show_ffcs=!show_ffcs;
4303 return D_O_K;
4304 }
4305 int32_t onShowLayerW()
4306 {
4307 show_walkflags=!show_walkflags;
4308 if(show_walkflags)
4309 show_effectflags = false;
4310 return D_O_K;
4311 }
4312 int32_t onShowLayerE()
4313 {
4314 show_effectflags=!show_effectflags;
4315 if(show_effectflags)
4316 show_walkflags = false;
4317 return D_O_K;
4318 }
4319 int32_t onShowFFScripts()
4320 {
4321 show_ff_scripts=!show_ff_scripts;
4322 return D_O_K;
4323 }
4324 int32_t onShowHitboxes()
4325 {
4326 show_hitboxes=!show_hitboxes;
4327 return D_O_K;
4328 }
4329 int32_t onShowInfoOpacity()
4330 {
4331 info_opacity = vbound(getnumber("Debug Info Opacity",info_opacity),0,255);
4332 zc_set_config("zc","debug_info_opacity",info_opacity);
4333 return D_O_K;
4334 }
4335
4336 int32_t onLightSwitch()
4337 {
4338 cheats_enqueue(Cheat::Light);
4339 return D_O_K;
4340 }
4341
4342 int32_t onGoTo();
4343 int32_t onGoToComplete();
4344
4345 9285900 bool handle_close_btn_quit()
4346 {
4347
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(close_button_quit)
4348 {
4349 close_button_quit=false;
4350 f_Quit(qEXIT);
4351 }
4352 9285900 return (exiting_program = Quit==qEXIT);
4353 }
4354
4355 9285900 void syskeys()
4356 {
4357 9285900 update_system_keys();
4358
4359 int32_t oldtitle_version;
4360
4361 9285900 poll_joystick();
4362
4363 9285900 handle_close_btn_quit();
4364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
9285900 if(Quit == qEXIT) return;
4365
4366
2/10
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9285900 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
9285900 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4367 {
4368 System();
4369 }
4370
4371 9285900 mouse_down=gui_mouse_b();
4372
4373
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(zc_read_system_key(KEY_F1))
4374 {
4375 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4376 {
4377 halt=!halt;
4378 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4379 }
4380 else
4381 {
4382 Throttlefps=!Throttlefps;
4383 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4384 }
4385 }
4386
4387 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4388 /*
4389 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4390 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4391 */
4392
4393
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(zc_read_system_key(KEY_F2))
4394 {
4395 ShowFPS=!ShowFPS;
4396 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4397 }
4398
4399
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285900 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4400
4401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285900 if(zc_read_system_key(KEY_F4) && Playing)
4402 {
4403 Paused=true;
4404 Advance=true;
4405 }
4406
4407
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(zc_read_system_key(KEY_F6)) onTryQuit();
4408
4409 #ifndef ALLEGRO_MACOSX
4410
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4411
4412
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4413 #else
4414 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4415
4416 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4417 #endif
4418
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9285900 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4419
4420
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if (zc_read_system_key(KEY_F12))
4421 {
4422 onSnapshot();
4423 }
4424
4425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285900 if(debug_enabled && zc_read_system_key(KEY_TAB))
4426 set_debug(!get_debug());
4427
4428
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(CheatModifierKeys())
4429 {
4430 for(Cheat c = (Cheat)1; c < Cheat::Last; c = (Cheat)(c+1))
4431 {
4432 if(!bindable_cheat(c))
4433 continue;
4434 if(get_debug() || cheat >= cheat_lvl(c))
4435 {
4436 if(checkcheat(c))
4437 cheats_hit_bind(c);
4438 }
4439 }
4440 }
4441
4442
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(volkeys)
4443 {
4444 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4445
4446 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4447
4448 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4449
4450 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4451 }
4452
4453
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9285900 if(!get_debug() || !SystemKeys || replay_is_replaying())
4454 9285900 goto bottom;
4455
4456 if(zc_readkey(KEY_D))
4457 {
4458 details = !details;
4459 rectfill(screen,0,0,319,7,BLACK);
4460 rectfill(screen,0,8,31,239,BLACK);
4461 rectfill(screen,288,8,319,239,BLACK);
4462 rectfill(screen,32,232,287,239,BLACK);
4463 }
4464
4465 if(zc_readkey(KEY_P)) Paused=!Paused;
4466
4467 //if(zc_readkey(KEY_P)) centerHero();
4468 if(zc_readkey(KEY_A))
4469 {
4470 Paused=true;
4471 Advance=true;
4472 }
4473
4474 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4475 #ifndef ALLEGRO_MACOSX
4476 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4477
4478 if(zc_readkey(KEY_F7))
4479 {
4480 Matrix(ss_speed, ss_density, 0);
4481 game_pal();
4482 }
4483 #else
4484 // The reason these are different on Mac in the first place is that
4485 // the OS doesn't let us use F9 and F10...
4486 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4487
4488 if(zc_readkey(KEY_F9))
4489 {
4490 Matrix(ss_speed, ss_density, 0);
4491 game_pal();
4492 }
4493 #endif
4494 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4495 {
4496 //change containers
4497 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4498 {
4499 //magic containers
4500 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4501 {
4502 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4503 }
4504 else
4505 {
4506 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4507 }
4508 }
4509 else
4510 {
4511 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4512 {
4513 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4514 }
4515 else
4516 {
4517 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4518 }
4519 }
4520 }
4521
4522 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4523 {
4524 //change containers
4525 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4526 {
4527 //magic containers
4528 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4529 {
4530 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4531 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4532 //heart containers
4533 }
4534 else
4535 {
4536 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4537 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4538 }
4539 }
4540 else
4541 {
4542 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4543 {
4544 game->set_magic(zc_max(game->get_magic()-1,0));
4545 }
4546 else
4547 {
4548 game->set_life(zc_max(game->get_life()-1,0));
4549 }
4550 }
4551 }
4552
4553 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4554
4555 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4556
4557 verifyBothWeapons();
4558
4559 bottom:
4560
4561
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(input_idle(true) > after_time())
4562 {
4563 Matrix(ss_speed, ss_density, 0);
4564 game_pal();
4565 }
4566 9285900 }
4567
4568 708271 void checkQuitKeys()
4569 {
4570 #ifndef ALLEGRO_MACOSX
4571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708271 times.
708271 if(key[KEY_F9]) f_Quit(qRESET);
4572
4573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 708271 times.
708271 if(key[KEY_F10]) f_Quit(qEXIT);
4574 #else
4575 if(key[KEY_F7]) f_Quit(qRESET);
4576
4577 if(key[KEY_F8]) f_Quit(qEXIT);
4578 #endif
4579 708271 }
4580
4581 9285900 bool CheatModifierKeys()
4582 {
4583 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4584 // to trigger cheats.
4585
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if (replay_is_replaying())
4586 9285900 return false;
4587
4588 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4589 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4590 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4591 {
4592 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4593 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4594 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4595 {
4596 return true;
4597 }
4598 }
4599 return false;
4600 9285900 }
4601
4602 //99:05:54, for some reason?
4603 #define OLDMAXTIME 21405240
4604 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4605 #define MAXTIME 1944000000
4606
4607 9286026 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4608 {
4609
1/2
✓ Branch 0 taken 9286026 times.
✗ Branch 1 not taken.
9286026 if(zcmusic!=NULL)
4610 {
4611 zcmusic_poll();
4612 }
4613 9286026 zcmixer_update(zcmixer, emusic_volume, FFCore.usr_music_volume, get_qr(qr_OLD_SCRIPT_VOLUME));
4614
4615 9286026 updatescr(allowwavy);
4616
4617 9286026 Advance=false;
4618
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9286026 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9286026 times.
9286026 while(Paused && !Advance && !Quit)
4619 {
4620 // have to call this, otherwise we'll get an infinite loop
4621 syskeys();
4622 if(allowF6Script)
4623 {
4624 FFCore.runF6Engine();
4625 }
4626 zc_throttle_fps();
4627
4628 #ifdef _WIN32
4629
4630 if(use_dwm_flush)
4631 {
4632 do_DwmFlush();
4633 }
4634
4635 #endif
4636
4637 // to keep music playing
4638 if(zcmusic!=NULL)
4639 {
4640 zcmusic_poll();
4641 }
4642
4643 update_hw_screen();
4644 }
4645
4646
2/2
✓ Branch 0 taken 9285914 times.
✓ Branch 1 taken 112 times.
9286026 if(Quit)
4647 112 return;
4648
4649
3/4
✓ Branch 0 taken 8984785 times.
✓ Branch 1 taken 301129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8984785 times.
9285914 if(Playing && game->get_time()<unsigned(get_qr(qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4650 8984785 game->change_time(1);
4651
4652 // Many mistakes have been make re: inputs, and we are stuck with many replays relying on those mistakes.
4653
4654 9285914 bool should_reset_down_state = !get_qr(qr_BROKEN_INPUT_DOWN_STATE);
4655
2/2
✓ Branch 0 taken 19197 times.
✓ Branch 1 taken 9266717 times.
9285914 if (replay_version_check(0, 16))
4656 9266717 should_reset_down_state = replay_version_check(11, 16);
4657
2/2
✓ Branch 0 taken 6949600 times.
✓ Branch 1 taken 2336314 times.
9285914 if (should_reset_down_state)
4658 {
4659
2/2
✓ Branch 0 taken 42053652 times.
✓ Branch 1 taken 2336314 times.
44389966 for (int i = 0; i < ZC_CONTROL_STATES; i++)
4660 42053652 down_control_states[i] = raw_control_state[i];
4661 2336314 }
4662
4663
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285900 times.
9285914 if (replay_is_active())
4664 {
4665
2/2
✓ Branch 0 taken 1270449 times.
✓ Branch 1 taken 8015451 times.
9285900 if (replay_version_check(3))
4666 8015451 replay_poll();
4667
4668
4/4
✓ Branch 0 taken 6946018 times.
✓ Branch 1 taken 2339882 times.
✓ Branch 2 taken 100535 times.
✓ Branch 3 taken 6845483 times.
9285900 if (replay_version_check(11) || replay_version_check(6, 8))
4669 2440417 replay_peek_input();
4670 9285900 }
4671
4672 9285914 load_control_called_this_frame = false;
4673
4674 9285914 poll_keyboard();
4675 9285914 update_keys();
4676
4677 9285914 ++frame;
4678
4679
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285900 times.
9285914 if (replay_is_replaying())
4680 9285900 replay_do_cheats();
4681 9285914 syskeys();
4682
4683 // The mouse variables can change from the mouse thread at anytime during a frame,
4684 // so save the result at the start so that replaying is consistent.
4685 9285914 script_mouse_x = gui_mouse_x();
4686 9285914 script_mouse_y = gui_mouse_y();
4687 9285914 script_mouse_z = mouse_z;
4688 9285914 script_mouse_b = mouse_b;
4689
4690 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4691 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4692 // approach here means it doesn't matter which call adds the cheat.
4693 9285914 cheats_execute_queued();
4694
4695
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 9285900 times.
9285914 if (replay_is_replaying())
4696 9285900 replay_peek_quit();
4697
2/2
✓ Branch 0 taken 9285900 times.
✓ Branch 1 taken 14 times.
9285914 if (GameFlags & GAMEFLAG_TRYQUIT)
4698 14 replay_step_quit(0);
4699
2/2
✓ Branch 0 taken 2934 times.
✓ Branch 1 taken 9282980 times.
9285914 if(allowF6Script)
4700 9282980 FFCore.runF6Engine();
4701
2/2
✓ Branch 0 taken 298 times.
✓ Branch 1 taken 9285616 times.
9285914 if (Quit)
4702 298 replay_step_quit(Quit);
4703 // Someday... maybe install a Turbo button here?
4704 9285914 zc_throttle_fps();
4705
4706 #ifdef _WIN32
4707
4708 if(use_dwm_flush)
4709 {
4710 do_DwmFlush();
4711 }
4712
4713 #endif
4714
4715 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4716
2/2
✓ Branch 0 taken 68758 times.
✓ Branch 1 taken 9217156 times.
9285914 if(sfxcleanup)
4717 9217156 sfx_cleanup();
4718
4719 9285914 jit_poll();
4720
4721 #ifdef __EMSCRIPTEN__
4722 // Yield the main thread back to the browser occasionally.
4723 if (is_headless())
4724 {
4725 static int rate = 10000;
4726 static int force_yield = rate;
4727 if (force_yield++ >= rate)
4728 {
4729 force_yield = 0;
4730 emscripten_sleep(0);
4731 }
4732 }
4733 #endif
4734
4735
4/6
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9285800 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
9285914 static bool test_mode_auto_restart = zc_get_config("zeldadx", "test_mode_auto_restart", false);
4736
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9285914 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9285914 if (zqtesting_mode && test_mode_auto_restart)
4737 {
4738 static auto last_write_time = fs::last_write_time(qstpath);
4739 static auto last_check = std::chrono::system_clock::now();
4740
4741 if (std::chrono::system_clock::now() - last_check > 200ms)
4742 {
4743 last_check = std::chrono::system_clock::now();
4744 auto write_time = fs::last_write_time(qstpath);
4745 if (last_write_time != write_time)
4746 {
4747 last_write_time = write_time;
4748 disableClickToFreeze = false;
4749 Quit = qRESET;
4750 replay_quit();
4751 }
4752 }
4753 }
4754 9286026 }
4755
4756 101 void zapout()
4757 {
4758 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4759 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4760
4761 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4762 101 script_drawing_commands.Clear();
4763
4764 // zap out
4765
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=1; i<=24; i++)
4766 {
4767 2424 draw_fuzzy(i);
4768 2424 advanceframe(true);
4769
4770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4771 {
4772 break;
4773 }
4774 2424 }
4775 101 }
4776
4777 101 void zapin()
4778 {
4779 101 FFCore.warpScriptCheck();
4780 101 draw_screen(tmpscr);
4781 101 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4782 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4783 101 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4784
4785 // zap out
4786 101 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4787
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2424 times.
2525 for(int32_t i=24; i>=1; i--)
4788 {
4789 2424 draw_fuzzy(i);
4790 2424 advanceframe(true);
4791
4792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2424 times.
2424 if(Quit)
4793 {
4794 break;
4795 }
4796 2424 }
4797 101 }
4798
4799
4800 65 void wavyout(bool showhero)
4801 {
4802 65 draw_screen(tmpscr, showhero);
4803 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4804
4805 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4806 65 clear_to_color(wavebuf,0);
4807 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4808
4809 static PALETTE wavepal;
4810
4811 int32_t ofs;
4812 65 int32_t amplitude=8;
4813
4814 65 int32_t wavelength=4;
4815 65 double palpos=0, palstep=4, palstop=126;
4816
4817 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4818
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4819 {
4820
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4821 {
4822 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4823 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4824 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4825 698880 }
4826
4827 2730 palpos+=palstep;
4828
4829
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4830 {
4831 2730 hw_palette = &wavepal;
4832 2730 update_hw_pal = true;
4833 2730 }
4834 else
4835 {
4836 hw_palette = &RAMpal;
4837 update_hw_pal = true;
4838 }
4839
4840
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4841 {
4842
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4843 {
4844 117411840 ofs=0;
4845
4846
4/4
✓ Branch 0 taken 57308160 times.
✓ Branch 1 taken 60103680 times.
✓ Branch 2 taken 28654080 times.
✓ Branch 3 taken 28654080 times.
117411840 if((j<i)&&(j&1))
4847 {
4848 28654080 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4849 28654080 }
4850
4851 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4852 117411840 }
4853 458640 }
4854
4855 2730 advanceframe(true);
4856
4857 // animate_combos();
4858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4859 break;
4860 2730 }
4861
4862 65 destroy_bitmap(wavebuf);
4863 65 }
4864
4865 65 void wavyin()
4866 {
4867 65 draw_screen(tmpscr);
4868 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4869
4870 65 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4871 65 clear_to_color(wavebuf,0);
4872 65 blit(framebuf,wavebuf,0,0,16,0,256,224);
4873
4874 static PALETTE wavepal;
4875
4876 //Breaks dark rooms.
4877 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4878 /*
4879 loadfullpal();
4880 loadlvlpal(DMaps[currdmap].color);
4881 ringcolor(false);
4882 */
4883 65 refreshpal=false;
4884 int32_t ofs;
4885 65 int32_t amplitude=8;
4886 65 int32_t wavelength=4;
4887 65 double palpos=168, palstep=4, palstop=126;
4888
4889 65 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4890
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 2730 times.
2795 for(int32_t i=0; i<168; i+=wavelength)
4891 {
4892
2/2
✓ Branch 0 taken 698880 times.
✓ Branch 1 taken 2730 times.
701610 for(int32_t l=0; l<256; l++)
4893 {
4894 698880 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4895 698880 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4896 698880 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4897 698880 }
4898
4899 2730 palpos-=palstep;
4900
4901
1/2
✓ Branch 0 taken 2730 times.
✗ Branch 1 not taken.
2730 if(palpos>=0)
4902 {
4903 2730 hw_palette = &wavepal;
4904 2730 update_hw_pal = true;
4905 2730 }
4906 else
4907 {
4908 hw_palette = &RAMpal;
4909 update_hw_pal = true;
4910 }
4911
4912
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 2730 times.
461370 for(int32_t j=0; j+playing_field_offset<224; j++)
4913 {
4914
2/2
✓ Branch 0 taken 117411840 times.
✓ Branch 1 taken 458640 times.
117870480 for(int32_t k=0; k<256; k++)
4915 {
4916 117411840 ofs=0;
4917
4918
4/4
✓ Branch 0 taken 59404800 times.
✓ Branch 1 taken 58007040 times.
✓ Branch 2 taken 30051840 times.
✓ Branch 3 taken 29352960 times.
117411840 if((j<(167-i))&&(j&1))
4919 {
4920 29352960 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4921 29352960 }
4922
4923 117411840 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4924 117411840 }
4925 458640 }
4926
4927 2730 advanceframe(true);
4928 // animate_combos();
4929
4930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2730 times.
2730 if(Quit)
4931 break;
4932 2730 }
4933
4934 65 destroy_bitmap(wavebuf);
4935 65 }
4936
4937 2168 void blackscr(int32_t fcnt,bool showsubscr)
4938 {
4939 2168 reset_pal_cycling();
4940 2168 script_drawing_commands.Clear();
4941
4942 2168 FFCore.warpScriptCheck();
4943 2168 bool showtime = game->should_show_time();
4944
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 64970 times.
67138 while(fcnt>0)
4945 {
4946 64970 clear_bitmap(framebuf);
4947
4948
2/2
✓ Branch 0 taken 25080 times.
✓ Branch 1 taken 39890 times.
64970 if(showsubscr)
4949 {
4950 39890 put_passive_subscr(framebuf,0,passive_subscreen_offset,showtime,sspUP);
4951
3/4
✓ Branch 0 taken 39890 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 750 times.
✓ Branch 3 taken 39140 times.
39890 if(get_qr(qr_SCRIPTDRAWSINWARPS) || (get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
4952 {
4953 750 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
4954 750 }
4955 39890 }
4956
4957 64970 advanceframe(true);
4958
4959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64970 times.
64970 if(Quit)
4960 break;
4961
4962 64970 --fcnt;
4963 }
4964 2168 }
4965
4966 1010 void openscreen(int32_t shape)
4967 {
4968 1010 reset_pal_cycling();
4969 1010 black_opening_count=0;
4970
4971
3/4
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 910 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100 times.
1010 if(COOLSCROLL || shape>-1)
4972 {
4973 910 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
4974 910 return;
4975 }
4976 else
4977 {
4978 100 Hero.setDontDraw(true);
4979 100 show_subscreen_dmap_dots=false;
4980 100 show_subscreen_numbers=false;
4981 // show_subscreen_items=false;
4982 100 show_subscreen_life=false;
4983 }
4984
4985 100 int32_t x=128;
4986
4987 100 FFCore.warpScriptCheck();
4988
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 8000 times.
8100 for(int32_t i=0; i<80; i++)
4989 {
4990 8000 draw_screen(tmpscr);
4991 //? draw_screen already draws the subscreen -DD
4992 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
4993 8000 x=128-(((i*128/80)/8)*8);
4994
4995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(x>0)
4996 {
4997 8000 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
4998 8000 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
4999 8000 }
5000
5001 8000 advanceframe(true);
5002
5003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8000 times.
8000 if(Quit)
5004 {
5005 break;
5006 }
5007 8000 }
5008
5009 100 Hero.setDontDraw(false);
5010 100 show_subscreen_items=true;
5011 100 show_subscreen_dmap_dots=true;
5012 1010 }
5013
5014 void closescreen(int32_t shape)
5015 {
5016 reset_pal_cycling();
5017 black_opening_count=0;
5018
5019 if(COOLSCROLL || shape>-1)
5020 {
5021 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5022 return;
5023 }
5024 else
5025 {
5026 Hero.setDontDraw(true);
5027 show_subscreen_dmap_dots=false;
5028 show_subscreen_numbers=false;
5029 // show_subscreen_items=false;
5030 show_subscreen_life=false;
5031 }
5032
5033 int32_t x=128;
5034
5035 FFCore.warpScriptCheck();
5036 for(int32_t i=79; i>=0; --i)
5037 {
5038 draw_screen(tmpscr);
5039 //? draw_screen already draws the subscreen -DD
5040 //put_passive_subscr(framebuf,0,passive_subscreen_offset,false,sspUP);
5041 x=128-(((i*128/80)/8)*8);
5042
5043 if(x>0)
5044 {
5045 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5046 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5047 }
5048
5049 advanceframe(true);
5050
5051 if(Quit)
5052 {
5053 break;
5054 }
5055 }
5056
5057 Hero.setDontDraw(false);
5058 show_subscreen_items=true;
5059 show_subscreen_dmap_dots=true;
5060 }
5061
5062 179 int32_t TriforceCount()
5063 {
5064 179 int32_t c=0;
5065
5066
2/2
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 179 times.
1611 for(int32_t i=1; i<=8; i++)
5067
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 1044 times.
2476 if(game->lvlitems[i]&liTRIFORCE)
5068 1044 ++c;
5069
5070 179 return c;
5071 }
5072
5073 int32_t onCustomGame()
5074 {
5075 int32_t file = getsaveslot();
5076
5077 if(file < 0)
5078 return D_O_K;
5079
5080 bool ret = (custom_game(file)!=0);
5081 return ret ? D_CLOSE : D_O_K;
5082 }
5083
5084 int32_t onContinue()
5085 {
5086 return D_CLOSE;
5087 }
5088
5089 int32_t onEsc() // Unused?? -L
5090 {
5091 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5092 }
5093
5094 int32_t onVsync()
5095 {
5096 Throttlefps = !Throttlefps;
5097 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5098 return D_O_K;
5099 }
5100
5101 int32_t onWinPosSave()
5102 {
5103 SaveWinPos = !SaveWinPos;
5104 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5105 return D_O_K;
5106 }
5107 int32_t onIntegerScaling()
5108 {
5109 scaleForceInteger = !scaleForceInteger;
5110 zc_set_config("zeldadx","scaling_force_integer",(int)scaleForceInteger);
5111 return D_O_K;
5112 }
5113 int32_t onStretchGame()
5114 {
5115 stretchGame = !stretchGame;
5116 zc_set_config("zeldadx","stretch_game_area",stretchGame?1:0);
5117 return D_O_K;
5118 }
5119
5120 int32_t onClickToFreeze()
5121 {
5122 ClickToFreeze = !ClickToFreeze;
5123 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5124 return D_O_K;
5125 }
5126
5127 int32_t OnSaveZCConfig()
5128 {
5129 if(jwin_alert3(
5130 "Save Configuration",
5131 "Are you sure that you wish to save your present configuration settings?",
5132 "This will overwrite your prior settings!",
5133 NULL,
5134 "&Yes",
5135 "&No",
5136 NULL,
5137 'y',
5138 'n',
5139 0,
5140 get_zc_font(font_lfont)) == 1)
5141 {
5142 save_game_configs();
5143 return D_O_K;
5144 }
5145 else return D_O_K;
5146 }
5147
5148 int32_t OnnClearQuestDir()
5149 {
5150 if(jwin_alert3(
5151 "Clear Current Directory Cache",
5152 "Are you sure that you wish to clear the current cached directory?",
5153 "This will default the current directory to `<ROOT>/quests` for this instance of ZC Player!",
5154 NULL,
5155 "&Yes",
5156 "&No",
5157 NULL,
5158 'y',
5159 'n',
5160 0,
5161 get_zc_font(font_lfont)) == 1)
5162 {
5163 zc_set_config("zeldadx","quest_dir","");
5164 flush_config_file();
5165 strcpy(qstdir,"");
5166 #ifdef __EMSCRIPTEN__
5167 em_sync_fs();
5168 #endif
5169 return D_O_K;
5170 }
5171 else return D_O_K;
5172 }
5173
5174
5175 int32_t onConsoleZASM()
5176 {
5177 if ( !zasm_debugger )
5178 {
5179 AlertDialog("WARNING: ZASM Debugger",
5180 "Enabling this will open the ZASM Debugger Console"
5181 "\nThis will likely grind ZC to a halt with lag."
5182 "\nTo make any use of this, it is suggested that you read"
5183 "\nthe documentation for 'void Breakpoint(char[] string);'"
5184 " in 'ZScript_Additions.txt'"
5185 "\nThis is not recommended for normal users,"
5186 " and is only intended for ZC developers,"
5187 "\nor quest developers coding directly in ZASM"
5188 "\nAre you sure that you wish to open the ZASM Debugger?",
5189 [&](bool ret,bool)
5190 {
5191 if(ret)
5192 {
5193 FFCore.ZASMPrint(true);
5194 }
5195 }).show();
5196 return D_O_K;
5197 }
5198 else
5199 {
5200 FFCore.ZASMPrint(false);
5201 return D_O_K;
5202 }
5203 }
5204
5205
5206 int32_t onConsoleZScript()
5207 {
5208 if ( !zscript_debugger )
5209 {
5210 AlertDialog("ZScript Debugger",
5211 "Enabling this will open the ZScript Debugger Console"
5212 "\nThis will display any messages logged by scripts,"
5213 " including script errors."
5214 "\nAre you sure that you wish to open the ZScript Debugger?",
5215 [&](bool ret,bool)
5216 {
5217 if(ret)
5218 {
5219 FFCore.ZScriptConsole(true);
5220 }
5221 }).show();
5222 return D_O_K;
5223 }
5224 else
5225 {
5226 FFCore.ZScriptConsole(false);
5227 return D_O_K;
5228 }
5229 }
5230
5231 int32_t onClrConsoleOnReload()
5232 {
5233 clearConsoleOnReload = !clearConsoleOnReload;
5234 zc_set_config("CONSOLE","clear_console_on_reload",clearConsoleOnReload?1:0);
5235 return D_O_K;
5236 }
5237 int32_t onClrConsoleOnLoad()
5238 {
5239 clearConsoleOnLoad = !clearConsoleOnLoad;
5240 zc_set_config("CONSOLE","clear_console_on_load",clearConsoleOnLoad?1:0);
5241 return D_O_K;
5242 }
5243
5244
5245 int32_t onFrameSkip()
5246 {
5247 FrameSkip = !FrameSkip;
5248 return D_O_K;
5249 }
5250
5251 int32_t onSaveDragResize()
5252 {
5253 SaveDragResize = !SaveDragResize;
5254 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5255 return D_O_K;
5256 }
5257
5258 int32_t onDragAspect()
5259 {
5260 DragAspect = !DragAspect;
5261 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5262 return D_O_K;
5263 }
5264
5265 int32_t onTransLayers()
5266 {
5267 TransLayers = !TransLayers;
5268 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5269 return D_O_K;
5270 }
5271
5272 int32_t onNESquit()
5273 {
5274 NESquit = !NESquit;
5275 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5276 return D_O_K;
5277 }
5278
5279 int32_t onVolKeys()
5280 {
5281 volkeys = !volkeys;
5282 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5283 return D_O_K;
5284 }
5285
5286 int32_t onShowFPS()
5287 {
5288 ShowFPS = !ShowFPS;
5289 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5290 return D_O_K;
5291 }
5292
5293 1095736200 bool is_Fkey(int32_t k)
5294 {
5295
2/2
✓ Branch 0 taken 111430800 times.
✓ Branch 1 taken 984305400 times.
1095736200 switch(k)
5296 {
5297 case KEY_F1:
5298 case KEY_F2:
5299 case KEY_F3:
5300 case KEY_F4:
5301 case KEY_F5:
5302 case KEY_F6:
5303 case KEY_F7:
5304 case KEY_F8:
5305 case KEY_F9:
5306 case KEY_F10:
5307 case KEY_F11:
5308 case KEY_F12:
5309 111430800 return true;
5310 }
5311
5312 984305400 return false;
5313 1095736200 }
5314
5315 void kb_getkey(DIALOG *d);
5316
5317 //Used by all keyboard key settings dialogues.
5318 void kb_clearjoystick(DIALOG *d)
5319 {
5320 d->flags|=D_SELECTED;
5321
5322 jwin_button_proc(MSG_DRAW,d,0);
5323 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5324 // text_mode(vc(11));
5325 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5326 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5327
5328 update_hw_screen(true);
5329
5330 clear_keybuf();
5331 int32_t k = next_press_key();
5332 clear_keybuf();
5333
5334 //shnarf
5335 //47=f1
5336 //59=esc
5337 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5338 // *((int32_t*)d->dp3) = k;
5339 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5340
5341
5342 d->flags&=~D_SELECTED;
5343 }
5344
5345 //Clears key to 0.
5346 //Used by all keyboard key settings dialogues.
5347 void kb_clearkey(DIALOG *d);
5348
5349 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5350 {
5351 switch(msg)
5352 {
5353 case MSG_KEY:
5354 case MSG_CLICK:
5355
5356 kb_clearjoystick(d);
5357
5358 while(gui_mouse_b())
5359 {
5360 clear_keybuf();
5361 rest(1);
5362 }
5363
5364 return D_REDRAW;
5365 }
5366
5367 return jwin_button_proc(msg,d,c);
5368 }
5369
5370 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5371 //Only used in keyboard settings dialogues to clear keys.
5372 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c);
5373
5374 int32_t j_getbtn(DIALOG *d)
5375 {
5376 d->flags|=D_SELECTED;
5377 jwin_button_proc(MSG_DRAW,d,0);
5378 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5379 // text_mode(vc(11));
5380 int32_t y = screen->h/2 - 12;
5381 textout_centre_ex(screen, font, "Press a button", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5382 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5383 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5384
5385 update_hw_screen(true);
5386
5387 int32_t b = next_joy_input(true);
5388 if (b == -2)
5389 return D_CLOSE;
5390
5391 if(b>=0)
5392 *((int32_t*)d->dp3) = b;
5393
5394 d->flags&=~D_SELECTED;
5395
5396 if (player)
5397 player->joy_on = TRUE;
5398
5399 return D_O_K;
5400 }
5401
5402 void j_getstick(DIALOG *d)
5403 {
5404 d->flags|=D_SELECTED;
5405 jwin_button_proc(MSG_DRAW,d,0);
5406 jwin_draw_win(screen, (screen->w-160)/2, (screen->h-48)/2, 160, 48, FR_WIN);
5407 // text_mode(vc(11));
5408 int32_t y = screen->h/2 - 12;
5409 textout_centre_ex(screen, font, "Move a stick (or DPAD)", screen->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5410 textout_centre_ex(screen, font, "ESC to cancel", screen->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5411 textout_centre_ex(screen, font, "SPACE to disable", screen->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5412
5413 update_hw_screen(true);
5414
5415 int32_t b = next_joy_input(false);
5416
5417 if(b>=0)
5418 *((int32_t*)d->dp3) = b;
5419
5420 d->flags&=~D_SELECTED;
5421
5422 if (player)
5423 player->joy_on = TRUE;
5424 }
5425
5426 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5427 {
5428 switch(msg)
5429 {
5430 case MSG_KEY:
5431 case MSG_CLICK:
5432
5433 int ret = j_getbtn(d);
5434 if (ret != D_O_K)
5435 return ret;
5436
5437 while(gui_mouse_b()) {
5438 rest(1);
5439 clear_keybuf();
5440 }
5441
5442 return D_REDRAW;
5443 }
5444
5445 return jwin_button_proc(msg,d,c);
5446 }
5447
5448 int32_t d_jstick_proc(int32_t msg,DIALOG *d,int32_t c)
5449 {
5450 switch(msg)
5451 {
5452 case MSG_KEY:
5453 case MSG_CLICK:
5454
5455 j_getstick(d);
5456
5457 while(gui_mouse_b()) {
5458 rest(1);
5459 clear_keybuf();
5460 }
5461
5462 return D_REDRAW;
5463 }
5464
5465 return jwin_button_proc(msg,d,c);
5466 }
5467
5468 //shnarf
5469 extern const char *key_str[];
5470 std::string get_keystr(int key);
5471
5472 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5473 //extern int32_t zcmusic_bufsz;
5474
5475 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5476 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80],
5477 str_primary_stick[80], str_secondary_stick[80];
5478
5479 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5480 {
5481 //these are here to bypass compiler warnings about unused arguments
5482 c=c;
5483
5484 if (d->w == 1)
5485 {
5486 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
5487 {
5488 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
5489 return D_CLOSE;
5490 }
5491 }
5492
5493 if(msg==MSG_DRAW)
5494 {
5495 switch(d->w)
5496 {
5497 case 0:
5498 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5499 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5500 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5501 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5502 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5503 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5504 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5505 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5506 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5507 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5508 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5509 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5510 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5511 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5512 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5513 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5514 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5515 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5516 break;
5517
5518 case 1:
5519 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5520 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5521 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5522 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5523 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5524 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5525 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5526 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5527 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5528 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5529 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5530 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5531 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5532 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5533 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5534 sprintf(str_primary_stick,"%03d\n%s",js_stick_1_x_stick,joystick_name(js_stick_1_x_stick));
5535 sprintf(str_secondary_stick,"%03d\n%s",js_stick_2_x_stick,joystick_name(js_stick_2_x_stick));
5536 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5537 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5538 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5539 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5540 break;
5541
5542 case 2:
5543 sprintf(str_a," %3d",midi_volume);
5544 sprintf(str_b," %3d",digi_volume);
5545 sprintf(str_l," %3d",emusic_volume);
5546 sprintf(str_m," %3dKB",zcmusic_bufsz);
5547 sprintf(str_r," %3d",sfx_volume);
5548 strcpy(str_s,pan_str[pan_style]);
5549 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5550 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5551 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5552 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5553 break;
5554 }
5555 }
5556
5557 return D_O_K;
5558 }
5559
5560 int32_t set_vol(void *dp3, int32_t d2)
5561 {
5562 switch(((int32_t*)dp3)[0])
5563 {
5564 case 0:
5565 midi_volume = zc_min(d2<<3,255);
5566 break;
5567
5568 case 1:
5569 digi_volume = zc_min(d2<<3,255);
5570 break;
5571
5572 case 2:
5573 emusic_volume = zc_min(d2<<3,255);
5574 break;
5575
5576 case 3:
5577 sfx_volume = zc_min(d2<<3,255);
5578 break;
5579 }
5580
5581 // text_mode(vc(11));
5582 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5583 return D_O_K;
5584 }
5585
5586 int32_t set_pan(void *dp3, int32_t d2)
5587 {
5588 pan_style = vbound(d2,0,3);
5589 // text_mode(vc(11));
5590 textout_right_ex(screen,get_zc_font(font_lfont_l), pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5591 return D_O_K;
5592 }
5593
5594 int32_t set_buf(void *dp3, int32_t d2)
5595 {
5596 // text_mode(vc(11));
5597 zcmusic_bufsz = d2 + 1;
5598 textprintf_right_ex(screen,get_zc_font(font_lfont_l), ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5599 return D_O_K;
5600 }
5601
5602 static int32_t gamepad_joys_list[] =
5603 {
5604 61,
5605 -1
5606 };
5607
5608 static int32_t gamepad_btn_list[] =
5609 {
5610 6,
5611 7,8,9,10,11,12,13,14,15,16,17,
5612 18,19,20,21,22,23,24,25,26,27,28,
5613 29,30,31,32,33,34,35,36,37,38,39,
5614 -1
5615 };
5616
5617 static int32_t gamepad_dirs_list[] =
5618 {
5619 40,41,42,43,
5620 44,45,46,47,
5621 48,49,50,51,
5622 52,53,54,55,
5623 56,57,58,59,
5624 60,
5625 -1
5626 };
5627
5628 static TABPANEL gamepad_tabs[] =
5629 {
5630 // (text)
5631 { (char *)"Controllers", D_SELECTED, gamepad_joys_list, 0, NULL },
5632 { (char *)"Buttons", 0, gamepad_btn_list, 0, NULL },
5633 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5634 { NULL, 0, NULL, 0, NULL }
5635 };
5636
5637 const char *joy_list(int32_t index, int32_t *list_size)
5638 {
5639 if (index == -1)
5640 {
5641 *list_size = al_get_num_joysticks();
5642 return NULL;
5643 }
5644
5645 ALLEGRO_JOYSTICK* joy = al_get_joystick(index);
5646 if (!joy)
5647 {
5648 return "?";
5649 }
5650
5651 return al_get_joystick_name(joy);
5652 }
5653
5654 114 static ListData joy__list(joy_list, &font);
5655
5656 static int32_t d_joylist_proc(int32_t msg,DIALOG *d,int32_t c)
5657 {
5658 int32_t d2 = d->d2;
5659 int32_t ret = jwin_droplist_proc(msg,d,c);
5660
5661 if(d2!=d->d2)
5662 {
5663 joystick_index = d->d2;
5664 ret |= D_REDRAW_ALL;
5665 }
5666
5667 return ret;
5668 }
5669
5670 static DIALOG gamepad_dlg[] =
5671 {
5672 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5673 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5674 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5675 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5676 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5677 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5678 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5679 // 6
5680 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5681 // 7
5682 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5683 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5684 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5685 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5686 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5687 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5688 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5689 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5690 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5691 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5692 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5693 // 18
5694 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5695 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5696 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5697 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5698 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5699 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5700 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5701 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5702 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5703 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5704 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5705 // 29
5706 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5707 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5708 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5709 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5710 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5711 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5712 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5713 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5714 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5715 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5716 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5717 // 40
5718 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5719 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5720 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5721 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5722 // 44
5723 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5724 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5725 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5726 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5727 // 48
5728 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5729 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5730 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5731 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5732 // 52
5733 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5734 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5735 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5736 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5737 // 56
5738 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Primary: Use Analog Stick (Ignore above and use below instead)", NULL, NULL },
5739 { d_jstick_proc, 22, 165, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Primary", NULL, &js_stick_1_x_stick },
5740 { d_jstick_proc, 22, 195, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Secondary", NULL, &js_stick_2_x_stick },
5741 { jwin_text_proc, 90, 165, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_primary_stick, NULL, NULL },
5742 { jwin_text_proc, 90, 195, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_secondary_stick, NULL, NULL },
5743
5744 // 61
5745 { d_joylist_proc, 22, 62, 150, 16, 0, 0, 0, 0, 0, 0, (void *) &joy__list, NULL, NULL },
5746
5747 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5748 };
5749
5750 static int32_t keyboard_keys_list[] =
5751 {
5752 6,7,8,9,10,
5753 11,12,13,14,15,16,17,18,19,20,
5754 21,22,23,24,25,26,27,28,29,30,
5755 31,32,33,34,35,36,37,38,39,40,
5756 -1
5757 };
5758
5759 static int32_t keyboard_dirs_list[] =
5760 {
5761 41,42,43,44,
5762 45,46,47,48,
5763 49,50,51,52,
5764 53,54,55,56,
5765 -1
5766 };
5767
5768 static int32_t keyboard_mods_list[] =
5769 {
5770 57,58,59,60,
5771 61,62,63,64,
5772 65,66,67,68,
5773 69,70,71,72,
5774 -1
5775 };
5776
5777 static TABPANEL keyboard_control_tabs[] =
5778 {
5779 // (text)
5780 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5781 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5782 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5783 { NULL, 0, NULL, 0, NULL }
5784 };
5785
5786 static DIALOG keyboard_control_dlg[] =
5787 {
5788 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5789 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5790 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5791 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5792 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5793 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5794 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5795 // Keys
5796 // 6
5797 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5798 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5799 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5800 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5801 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5802 // 11
5803 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5804 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5805 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5806 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5807 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5808 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5809 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5810 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5811 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5812 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5813 // 21
5814 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5815 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5816 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5817 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5818 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5819 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5820 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5821 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5822 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5823 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5824 // 31
5825 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5826 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5827 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5828 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5829 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5830 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5831 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5832 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5833 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5834 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5835 // Dirs
5836 // 41
5837 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5838 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5839 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5840 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5841 // 45
5842 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5843 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5844 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5845 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5846 // 49
5847 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5848 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5849 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5850 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5851 // 53
5852 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5853 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5854 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5855 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5856 // Mods
5857 // 57
5858 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5859 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5860 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5861 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5862 // 61
5863 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5864 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5865 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5866 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5867 // 65
5868 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5869 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5870 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5871 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5872 // 69
5873 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5874 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5875 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5876 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5877 // 73
5878 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5879 };
5880
5881 /*
5882 int32_t midi_dp[3] = {0,147,104};
5883 int32_t digi_dp[3] = {1,147,120};
5884 int32_t pan_dp[3] = {0,147,136};
5885 int32_t buf_dp[3] = {0,147,152};
5886 */
5887 int32_t midi_dp[3] = {0,0,0};
5888 int32_t digi_dp[3] = {1,0,0};
5889 int32_t emus_dp[3] = {2,0,0};
5890 int32_t buf_dp[3] = {0,0,0};
5891 int32_t sfx_dp[3] = {3,0,0};
5892 int32_t pan_dp[3] = {0,0,0};
5893
5894 static DIALOG sound_dlg[] =
5895 {
5896 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5897 114 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5898 114 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5899 114 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5900 114 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5901 114 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5902 114 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
5903 114 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
5904 114 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
5905 114 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
5906 114 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
5907 // 10
5908 114 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
5909 114 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
5910 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5911 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5912 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5913 114 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
5914 114 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
5915 114 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
5916 114 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
5917 114 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
5918 //20
5919 114 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
5920 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5921 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5922 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5923 114 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
5924 114 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
5925 114 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
5926 114 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
5927 114 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
5928 114 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
5929 //30
5930 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5931 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5932 114 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5933 114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5934 };
5935
5936 char zc_builddate[80];
5937 char zc_aboutstr[80];
5938
5939 static DIALOG about_dlg[] =
5940 {
5941 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5942 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
5943 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5944 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
5945 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5946 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
5947 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
5948 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
5949 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
5950 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
5951 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5952 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5953 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5954 };
5955
5956
5957 static DIALOG quest_dlg[] =
5958 {
5959 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
5960 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
5961 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
5962 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
5963 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5964 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
5965 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, header_version_nul_term, NULL, NULL },
5966 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
5967 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5968 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
5969 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
5970 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
5971 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
5972 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5973 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5974 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5975 };
5976
5977 static DIALOG triforce_dlg[] =
5978 {
5979 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
5980 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
5981 // 1
5982 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
5983 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
5984 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
5985 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
5986 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
5987 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
5988 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
5989 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
5990 // 9
5991 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
5992 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5993 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5994 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5995 };
5996
5997 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
5998 {
5999 go();
6000 int32_t ret=0;
6001 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6002 comeback();
6003 return ret != 0;
6004 }
6005
6006
6007 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6008 {
6009 if(def!=modulepath)
6010 strcpy(modulepath,def);
6011
6012 if(!usefilename)
6013 {
6014 int32_t i=(int32_t)strlen(modulepath);
6015
6016 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6017 modulepath[i--]=0;
6018 }
6019
6020 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6021 int32_t ret=0;
6022 int32_t sel=0;
6023
6024 if(list==NULL)
6025 {
6026 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,get_zc_font(font_lfont));
6027 }
6028 else
6029 {
6030 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, get_zc_font(font_lfont));
6031 }
6032
6033 return ret!=0;
6034 }
6035
6036 int32_t onToggleRecordingNewSaves()
6037 {
6038 if (zc_get_config("zeldadx", "replay_new_saves", false))
6039 {
6040 zc_set_config("zeldadx", "replay_new_saves", false);
6041 }
6042 else
6043 {
6044 zc_set_config("zeldadx", "replay_new_saves", true);
6045 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6046 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6047 }
6048 return D_O_K;
6049 }
6050
6051 int32_t onToggleSnapshotAllFrames()
6052 {
6053 replay_set_snapshot_all_frames(!replay_is_snapshot_all_frames());
6054 return D_O_K;
6055 }
6056
6057 int32_t onStopReplayOrRecord()
6058 {
6059 if (replay_is_replaying())
6060 {
6061 replay_quit();
6062 }
6063 else if (replay_get_mode() == ReplayMode::Record)
6064 {
6065 if (!replay_get_meta_bool("test_mode"))
6066 {
6067 jwin_alert("Recording", "You cannot stop recording a save file.",
6068 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6069 return D_CLOSE;
6070 }
6071
6072 if (jwin_alert("Stop Recording",
6073 "Save replay to disk and stop recording?",
6074 "This will stop the recording.",
6075 NULL,
6076 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6077 return D_CLOSE;
6078
6079 replay_save();
6080 replay_stop();
6081 }
6082 return D_O_K;
6083 }
6084
6085 static int32_t handle_on_load_replay(ReplayMode mode)
6086 {
6087 if (Playing)
6088 {
6089 if (jwin_alert("Replay - Warning!",
6090 "Loading a replay will exit the current game.",
6091 "All unsaved progress will be lost.",
6092 "Do you wish to continue?",
6093 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6094 return D_CLOSE;
6095 }
6096
6097 std::string mode_string = replay_mode_to_string(mode);
6098 mode_string[0] = std::toupper(mode_string[0]);
6099
6100 std::string line_1 = "Select a replay file to play back.";
6101 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6102 std::string line_3 = "You can stop the replay and take over manually any time.";
6103 if (mode == ReplayMode::Update)
6104 {
6105 line_1 = "Select a replay file to update.";
6106 line_2 = "WARNING: be sure to back up the zplay file";
6107 line_3 = "and verify that the updated replay works as expected!";
6108 }
6109
6110 if (jwin_alert(mode_string.c_str(),
6111 line_1.c_str(),
6112 line_2.c_str(),
6113 line_3.c_str(),
6114 "OK","Nevermind",13,27,get_zc_font(font_lfont)) == 1)
6115 {
6116 char replay_path[2048];
6117 strcpy(replay_path, "replays/");
6118 if (jwin_file_select_ex(
6119 fmt::format("Load Replay ({})", REPLAY_EXTENSION).c_str(),
6120 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6121 return D_CLOSE;
6122
6123 replay_quit();
6124 load_replay_file_deferred(mode, replay_path);
6125 Quit = qRESET;
6126 return D_CLOSE;
6127 }
6128 return D_O_K;
6129 }
6130
6131 int32_t onLoadReplay()
6132 {
6133 return handle_on_load_replay(ReplayMode::Replay);
6134 }
6135
6136 int32_t onLoadReplayAssert()
6137 {
6138 return handle_on_load_replay(ReplayMode::Assert);
6139 }
6140
6141 int32_t onLoadReplayUpdate()
6142 {
6143 return handle_on_load_replay(ReplayMode::Update);
6144 }
6145
6146 int32_t onSaveReplay()
6147 {
6148 if (replay_get_mode() == ReplayMode::Record)
6149 {
6150 if (!replay_get_meta_bool("test_mode"))
6151 {
6152 if (jwin_alert("Save Replay",
6153 "This will save a copy of the replay up to this point.",
6154 "The official replay file will be untouched.",
6155 "Do you wish to continue?",
6156 "Yes","No",13,27,get_zc_font(font_lfont)) != 1)
6157 return D_CLOSE;
6158
6159 char replay_path[2048];
6160 strcpy(replay_path, replay_get_replay_path().string().c_str());
6161 if (jwin_file_select_ex(
6162 fmt::format("Save Replay ({})", REPLAY_EXTENSION).c_str(),
6163 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, get_zc_font(font_lfont)) == 0)
6164 return D_CLOSE;
6165
6166 if (fileexists(replay_path))
6167 {
6168 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6169 NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6170 return D_CLOSE;
6171 }
6172
6173 replay_save(replay_path);
6174 }
6175 else
6176 {
6177 replay_save();
6178 }
6179 }
6180 return D_O_K;
6181 }
6182
6183 static MENU replay_menu[] =
6184 {
6185 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6186 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6187 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6188 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6189 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6190 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6191 { (char *)"Enable snapshot all frames", onToggleSnapshotAllFrames,NULL, 0, NULL },
6192
6193 { NULL, NULL, NULL, 0, NULL }
6194 };
6195
6196 static DIALOG credits_dlg[] =
6197 {
6198 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6199 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "ZQuest Classic Credits", NULL, NULL },
6200 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6201 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6202 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6203 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6204 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6205 };
6206
6207 114 static ListData dmap_list(dmaplist, &font);
6208
6209 static DIALOG goto_dlg[] =
6210 {
6211 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6212 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6213 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6214 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6215 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6216 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6217 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6218 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6219 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6220 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6221 };
6222
6223 int32_t onGoTo()
6224 {
6225 bool music = false;
6226 music = music;
6227 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6228
6229 goto_dlg[0].dp2=get_zc_font(font_lfont);
6230 goto_dlg[4].d2=cheat_goto_dmap;
6231 goto_dlg[6].dp=cheat_goto_screen_str;
6232
6233 clear_keybuf();
6234
6235 large_dialog(goto_dlg);
6236
6237 if(do_zqdialog(goto_dlg,4)==1)
6238 {
6239 // dmap, screen
6240 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6241 };
6242
6243 return D_O_K;
6244 }
6245
6246 int32_t onGoToComplete()
6247 {
6248 if(!Playing)
6249 {
6250 return D_O_K;
6251 }
6252
6253 enter_sys_pal();
6254 music_pause();
6255 pause_all_sfx();
6256 onGoTo();
6257 eat_buttons();
6258
6259 zc_readrawkey(KEY_ESC);
6260
6261 exit_sys_pal();
6262 music_resume();
6263 resume_all_sfx();
6264 return D_O_K;
6265 }
6266
6267 int32_t onCredits()
6268 {
6269 return D_O_K;
6270 }
6271
6272 const char *midilist(int32_t index, int32_t *list_size)
6273 {
6274 if(index<0)
6275 {
6276 *list_size=0;
6277
6278 for(int32_t i=0; i<MAXMIDIS; i++)
6279 if(tunes[i].data)
6280 ++(*list_size);
6281
6282 return NULL;
6283 }
6284
6285 int32_t i=0,m=0;
6286
6287 while(m<=index && i<=MAXMIDIS)
6288 {
6289 if(tunes[i].data)
6290 ++m;
6291
6292 ++i;
6293 }
6294
6295 --i;
6296
6297 if(i==MAXMIDIS && m<index)
6298 return "(null)";
6299
6300 return tunes[i].title;
6301 }
6302
6303 /* ------- MIDI info stuff -------- */
6304
6305 char *text;
6306 midi_info *zmi;
6307 bool dialog_running;
6308 bool listening;
6309
6310 void get_info(int32_t index);
6311
6312 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6313 {
6314 int32_t d2 = d->d2;
6315 int32_t ret = jwin_droplist_proc(msg,d,c);
6316
6317 if(d2!=d->d2)
6318 {
6319 get_info(d->d2);
6320 }
6321
6322 return ret;
6323 }
6324
6325 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6326 {
6327 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6328
6329 int32_t ret = jwin_button_proc(msg,d,c);
6330
6331 if(ret == D_CLOSE)
6332 {
6333 // get current midi index
6334 int32_t index = (d+(d->d1))->d2;
6335 int32_t i=0, m=0;
6336
6337 while(m<=index && i<=MAXMIDIS)
6338 {
6339 if(tunes[i].data)
6340 ++m;
6341
6342 ++i;
6343 }
6344
6345 --i;
6346 jukebox(i);
6347 listening = true;
6348 ret = D_O_K;
6349 }
6350
6351 return ret;
6352 }
6353
6354 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6355 {
6356 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6357
6358 int32_t ret = jwin_button_proc(msg,d,c);
6359
6360 if(ret == D_CLOSE)
6361 {
6362 // get current midi index
6363 int32_t index = (d+(d->d1))->d2;
6364 int32_t i=0, m=0;
6365
6366 while(m<=index && i<=MAXMIDIS)
6367 {
6368 if(tunes[i].data)
6369 ++m;
6370
6371 ++i;
6372 }
6373
6374 --i;
6375
6376 // get file name
6377
6378 int32_t sel=0;
6379 //struct ffblk f;
6380 char title[40] = "Save MIDI: ";
6381 char fname[2048];
6382 memset(fname,0,2048);
6383 static EXT_LIST list[] =
6384 {
6385 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6386 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6387 { NULL, NULL }
6388 };
6389
6390 strcpy(title+11, tunes[i].title);
6391 title[39] = '\0';
6392
6393 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, get_zc_font(font_lfont))==0)
6394 goto done;
6395
6396 if(exists(fname))
6397 {
6398 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',get_zc_font(font_lfont))==2)
6399 goto done;
6400 }
6401
6402 // save midi i
6403
6404 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6405 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,get_zc_font(font_lfont));
6406
6407 done:
6408 chop_path(fname);
6409 ret = D_REDRAW;
6410 }
6411
6412 return ret;
6413 }
6414
6415 114 static ListData midi_list(midilist, &font);
6416
6417 static DIALOG midi_dlg[] =
6418 {
6419 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6420 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6421 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6422 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6423 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6424 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6425 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6426 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6427 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6428 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6429 };
6430
6431 void get_info(int32_t index)
6432 {
6433 int32_t i=0, m=0;
6434
6435 while(m<=index && i<=MAXMIDIS)
6436 {
6437 if(tunes[i].data)
6438 ++m;
6439
6440 ++i;
6441 }
6442
6443 --i;
6444
6445 if(i==MAXMIDIS && m<index)
6446 strcpy(text,"(null)");
6447 else
6448 {
6449 get_midi_info((MIDI*)tunes[i].data,zmi);
6450 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6451 }
6452
6453 midi_dlg[0].dp2=get_zc_font(font_lfont);
6454 midi_dlg[3].dp = text;
6455 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6456 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6457
6458 if(dialog_running)
6459 {
6460 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6461 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6462 }
6463 }
6464
6465 int32_t onMIDICredits()
6466 {
6467 text = (char*)malloc(4096);
6468 zmi = (midi_info*)malloc(sizeof(midi_info));
6469
6470 if(!text || !zmi)
6471 {
6472 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
6473 return D_O_K;
6474 }
6475
6476 bool do_pause_midi = midi_pos >= 0 && currmidi;
6477 auto restore_midi = currmidi;
6478 if(do_pause_midi)
6479 {
6480 paused_midi_pos = midi_pos;
6481 stop_midi();
6482 midi_suspended = midissuspHALTED;
6483 }
6484
6485 midi_dlg[0].dp2=get_zc_font(font_lfont);
6486 midi_dlg[2].d1 = 0;
6487 midi_dlg[2].d2 = 0;
6488 midi_dlg[4].flags = D_EXIT;
6489 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6490
6491 listening = false;
6492 dialog_running=false;
6493 get_info(0);
6494
6495 dialog_running=true;
6496
6497 large_dialog(midi_dlg);
6498
6499 do_zqdialog(midi_dlg,0);
6500 dialog_running=false;
6501
6502 if(listening)
6503 music_stop();
6504
6505 if(do_pause_midi)
6506 {
6507 // TODO: this probably doesn't resume midis nicely when scrolling (or in some other inner-gameloop).
6508 midi_suspended = midissuspRESUME;
6509 currmidi = restore_midi;
6510 midi_pos = paused_midi_pos;
6511 }
6512
6513 if(text) free(text);
6514 if(zmi) free(zmi);
6515 return D_O_K;
6516 }
6517
6518 int32_t onAbout()
6519 {
6520 char buf1[80]={0};
6521 std::ostringstream oss;
6522 sprintf(buf1,"%s, Version: %s", ZC_PLAYER_NAME,ZC_PLAYER_V);
6523 oss << buf1 << '\n';
6524 sprintf(buf1, "%s", ALPHA_VER_STR);
6525 oss << buf1 << '\n';
6526 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6527 oss << buf1 << '\n';
6528 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6529 oss << buf1 << '\n';
6530 sprintf(buf1, "Tag: %s", getReleaseTag());
6531 oss << buf1 << '\n';
6532
6533 InfoDialog("About ZC", oss.str()).show();
6534 return D_O_K;
6535 }
6536
6537 int32_t onQuest()
6538 {
6539 char fname[100];
6540 strcpy(fname, get_filename(qstpath));
6541 quest_dlg[0].dp2=get_zc_font(font_lfont);
6542 quest_dlg[1].dp = fname;
6543
6544 if(QHeader.quest_number==0)
6545 sprintf(str_a,"Custom");
6546 else
6547 sprintf(str_a,"%d",QHeader.quest_number);
6548
6549 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6550
6551 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6552 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6553
6554 large_dialog(quest_dlg);
6555
6556 do_zqdialog(quest_dlg, 0);
6557 return D_O_K;
6558 }
6559
6560 void call_vidmode_dlg();
6561 int32_t onVidMode()
6562 {
6563 call_vidmode_dlg();
6564 return D_O_K;
6565 }
6566
6567 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6568 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6569 //Added an extra statement, so that if the key is cleared to 0, the cleared
6570 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6571
6572 void load_ukeys(int32_t* arr)
6573 {
6574 arr[ukey_a] = Akey;
6575 arr[ukey_b] = Bkey;
6576 arr[ukey_s] = Skey;
6577 arr[ukey_l] = Lkey;
6578 arr[ukey_r] = Rkey;
6579 arr[ukey_p] = Pkey;
6580 arr[ukey_ex1] = Exkey1;
6581 arr[ukey_ex2] = Exkey2;
6582 arr[ukey_ex3] = Exkey3;
6583 arr[ukey_ex4] = Exkey4;
6584 arr[ukey_du] = DUkey;
6585 arr[ukey_dd] = DDkey;
6586 arr[ukey_dl] = DLkey;
6587 arr[ukey_dr] = DRkey;
6588 arr[ukey_mod1a] = cheat_modifier_keys[0];
6589 arr[ukey_mod1b] = cheat_modifier_keys[1];
6590 arr[ukey_mod2a] = cheat_modifier_keys[2];
6591 arr[ukey_mod2b] = cheat_modifier_keys[3];
6592 };
6593
6594 static const char* ukey_names[] = {
6595 "A", "B", "Start", "L", "R", "Map",
6596 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
6597 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
6598 "Cheat Mod R1", "Cheat Mod R2",
6599 };
6600 std::string get_ukey_name(int32_t k)
6601 {
6602 if (k < num_ukey) return ukey_names[k];
6603 return "";
6604 }
6605
6606 int32_t onKeyboard()
6607 {
6608 int32_t a = Akey;
6609 int32_t b = Bkey;
6610 int32_t s = Skey;
6611 int32_t l = Lkey;
6612 int32_t r = Rkey;
6613 int32_t p = Pkey;
6614 int32_t ex1 = Exkey1;
6615 int32_t ex2 = Exkey2;
6616 int32_t ex3 = Exkey3;
6617 int32_t ex4 = Exkey4;
6618 int32_t du = DUkey;
6619 int32_t dd = DDkey;
6620 int32_t dl = DLkey;
6621 int32_t dr = DRkey;
6622 int32_t mod1a = cheat_modifier_keys[0];
6623 int32_t mod1b = cheat_modifier_keys[1];
6624 int32_t mod2a = cheat_modifier_keys[2];
6625 int32_t mod2b = cheat_modifier_keys[3];
6626 bool done=false;
6627 int32_t ret;
6628
6629 keyboard_control_dlg[0].dp2=get_zc_font(font_lfont);
6630
6631 large_dialog(keyboard_control_dlg);
6632
6633 while(!done)
6634 {
6635 ret = do_zqdialog(keyboard_control_dlg,3);
6636
6637 if(ret==3) // OK
6638 {
6639 int32_t ukeys[num_ukey];
6640 load_ukeys(ukeys);
6641 std::vector<std::string> uniqueError;
6642 for(int32_t q = 0; q < num_ukey; ++q)
6643 {
6644 for(int32_t p = q+1; p < num_ukey; ++p)
6645 {
6646 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
6647 {
6648 char buf[64];
6649 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
6650 std::string str(buf);
6651 uniqueError.push_back(str);
6652 }
6653 }
6654 }
6655 if(uniqueError.size() == 0)
6656 {
6657 done = true;
6658 save_control_configs(true);
6659 }
6660 else
6661 {
6662 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
6663 box_out("Cannot have duplicate keybinds!"); box_eol();
6664 for(std::vector<std::string>::iterator it = uniqueError.begin();
6665 it != uniqueError.end(); ++it)
6666 {
6667 box_out((*it).c_str()); box_eol();
6668 }
6669 box_end(true);
6670 }
6671 }
6672 else // Cancel
6673 {
6674 Akey = a;
6675 Bkey = b;
6676 Skey = s;
6677 Lkey = l;
6678 Rkey = r;
6679 Pkey = p;
6680 Exkey1 = ex1;
6681 Exkey2 = ex2;
6682 Exkey3 = ex3;
6683 Exkey4 = ex4;
6684 DUkey = du;
6685 DDkey = dd;
6686 DLkey = dl;
6687 DRkey = dr;
6688 cheat_modifier_keys[0] = mod1a;
6689 cheat_modifier_keys[1] = mod1b;
6690 cheat_modifier_keys[2] = mod2a;
6691 cheat_modifier_keys[3] = mod2b;
6692
6693 done=true;
6694 }
6695
6696 rest(1);
6697 }
6698
6699 return D_O_K;
6700 }
6701
6702 int32_t onGamepad()
6703 {
6704 if (al_get_num_joysticks() == 0)
6705 {
6706 InfoDialog("ZC", "No gamepads detected.").show();
6707 return D_O_K;
6708 }
6709
6710 int32_t a = Abtn;
6711 int32_t b = Bbtn;
6712 int32_t s = Sbtn;
6713 int32_t l = Lbtn;
6714 int32_t r = Rbtn;
6715 int32_t m = Mbtn;
6716 int32_t p = Pbtn;
6717 int32_t ex1 = Exbtn1;
6718 int32_t ex2 = Exbtn2;
6719 int32_t ex3 = Exbtn3;
6720 int32_t ex4 = Exbtn4;
6721 int32_t up = DUbtn;
6722 int32_t down = DDbtn;
6723 int32_t left = DLbtn;
6724 int32_t right = DRbtn;
6725 int32_t joy = joystick_index;
6726 int32_t stick_1 = js_stick_1_x_stick;
6727 int32_t stick_2 = js_stick_2_x_stick;
6728
6729 gamepad_dlg[0].dp2=get_zc_font(font_lfont);
6730 if(analog_movement)
6731 gamepad_dlg[56].flags|=D_SELECTED;
6732 else
6733 gamepad_dlg[56].flags&=~D_SELECTED;
6734
6735 // TODO: should use controller device GUID or name instead of index, otherwise this value is not
6736 // consistent unless exact same number of joysticks is always connected. Name is problematic b/c
6737 // xinput driver doesn't actually get a name (at least, doesn't for my Xbox controller).
6738 // TODO: should store gamepad control mappings per-controller, otherwise switching joystick
6739 // requires remapping every time.
6740 if (joystick_index >= al_get_num_joysticks())
6741 joystick_index = 0;
6742 gamepad_dlg[61].d2 = joystick_index;
6743
6744 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6745 if (!gamepad_dlg_cur_joystick)
6746 {
6747 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6748 return D_CLOSE;
6749 }
6750
6751 large_dialog(gamepad_dlg);
6752
6753 int32_t ret = do_zqdialog(gamepad_dlg,4);
6754
6755 if(ret == 4) //OK
6756 {
6757 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
6758 joystick_index = gamepad_dlg[61].d2;
6759 gamepad_dlg_cur_joystick = al_get_joystick(joystick_index);
6760 if (!gamepad_dlg_cur_joystick)
6761 {
6762 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
6763 return D_CLOSE;
6764 }
6765 js_stick_1_y_stick = js_stick_1_x_stick;
6766 js_stick_2_y_stick = js_stick_2_x_stick;
6767 save_control_configs(false);
6768 }
6769 else //Cancel
6770 {
6771 Abtn = a;
6772 Bbtn = b;
6773 Sbtn = s;
6774 Lbtn = l;
6775 Rbtn = r;
6776 Mbtn = m;
6777 Pbtn = p;
6778 Exbtn1 = ex1;
6779 Exbtn2 = ex2;
6780 Exbtn3 = ex3;
6781 Exbtn4 = ex4;
6782 DUbtn = up;
6783 DDbtn = down;
6784 DLbtn = left;
6785 DRbtn = right;
6786 joystick_index = joy;
6787 js_stick_1_x_stick = stick_1;
6788 js_stick_2_x_stick = stick_2;
6789 }
6790
6791 return D_O_K;
6792 }
6793
6794 int32_t onCheatKeys()
6795 {
6796 int32_t oldcheats[Cheat::Last][2];
6797 memcpy(oldcheats, cheatkeys, sizeof(cheatkeys));
6798
6799 bool done=false;
6800
6801 while(!done)
6802 {
6803 bool confirm = false;
6804 CheatKeysDialog(&confirm).show();
6805 if(confirm) // OK
6806 {
6807 std::vector<std::string> uniqueError;
6808 char buf[512];
6809 for(size_t q = 1; q < Cheat::Last; ++q)
6810 {
6811 if(cheatkeys[q][1] && !cheatkeys[q][0])
6812 {
6813 cheatkeys[q][0] = cheatkeys[q][1];
6814 cheatkeys[q][1] = 0;
6815 }
6816 }
6817 for(size_t q = 1; q < Cheat::Last; ++q)
6818 {
6819 if(!bindable_cheat((Cheat)q)) continue;
6820 for(size_t p = q+1; p < Cheat::Last; ++p)
6821 {
6822 if(!bindable_cheat((Cheat)p)) continue;
6823 for(size_t q2 = 0; q2 <= 1; ++q2)
6824 for(size_t p2 = 0; p2 <= 1; ++p2)
6825 {
6826 if(cheatkeys[q][q2] == cheatkeys[p][p2] && cheatkeys[q][q2] != 0)
6827 {
6828 uniqueError.push_back(fmt::format("'{}' ({}) conflicts with '{}' ({}) - both '{}'",
6829 cheat_to_string((Cheat)q), q2?"Alt":"Main",
6830 cheat_to_string((Cheat)p), p2?"Alt":"Main",
6831 get_keystr(cheatkeys[q][q2])));
6832 }
6833 }
6834 }
6835 }
6836 if(uniqueError.size() == 0)
6837 {
6838 done = true;
6839 save_cheatkeys();
6840 }
6841 else
6842 {
6843 box_start(1, "Duplicate Keys", get_zc_font(font_lfont), get_zc_font(font_sfont), false, 500,400, 2);
6844 box_out("Cannot have duplicate keybinds!"); box_eol();
6845 for(std::vector<std::string>::iterator it = uniqueError.begin();
6846 it != uniqueError.end(); ++it)
6847 {
6848 box_out((*it).c_str()); box_eol();
6849 }
6850 box_end(true);
6851 }
6852 }
6853 else // Cancel
6854 {
6855 memcpy(cheatkeys, oldcheats, sizeof(cheatkeys));
6856 done=true;
6857 }
6858 rest(1);
6859 }
6860
6861 return D_O_K;
6862 }
6863
6864 int32_t onSound()
6865 {
6866 if (get_qr(qr_OLD_SCRIPT_VOLUME))
6867 {
6868 if (FFCore.coreflags & FFCORE_SCRIPTED_MIDI_VOLUME)
6869 {
6870 master_volume(-1, ((int32_t)FFCore.usr_midi_volume));
6871 }
6872 if (FFCore.coreflags & FFCORE_SCRIPTED_DIGI_VOLUME)
6873 {
6874 master_volume((int32_t)(FFCore.usr_digi_volume), 1);
6875 }
6876 if (FFCore.coreflags & FFCORE_SCRIPTED_MUSIC_VOLUME)
6877 {
6878 emusic_volume = (int32_t)FFCore.usr_music_volume;
6879 }
6880 if (FFCore.coreflags & FFCORE_SCRIPTED_SFX_VOLUME)
6881 {
6882 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
6883 }
6884 }
6885 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
6886 {
6887 pan_style = (int32_t)FFCore.usr_panstyle;
6888 }
6889
6890 int32_t m = midi_volume;
6891 int32_t d = digi_volume;
6892 int32_t e = emusic_volume;
6893 int32_t b = zcmusic_bufsz;
6894 int32_t s = sfx_volume;
6895 int32_t p = pan_style;
6896 pan_style = vbound(pan_style,0,3);
6897
6898 sound_dlg[0].dp2=get_zc_font(font_lfont);
6899
6900 large_dialog(sound_dlg);
6901
6902 midi_dp[1] = sound_dlg[6].x;
6903 midi_dp[2] = sound_dlg[6].y;
6904 digi_dp[1] = sound_dlg[7].x;
6905 digi_dp[2] = sound_dlg[7].y;
6906 emus_dp[1] = sound_dlg[8].x;
6907 emus_dp[2] = sound_dlg[8].y;
6908 buf_dp[1] = sound_dlg[9].x;
6909 buf_dp[2] = sound_dlg[9].y;
6910 sfx_dp[1] = sound_dlg[10].x;
6911 sfx_dp[2] = sound_dlg[10].y;
6912 pan_dp[1] = sound_dlg[11].x;
6913 pan_dp[2] = sound_dlg[11].y;
6914 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
6915 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
6916 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
6917 sound_dlg[18].d2 = zcmusic_bufsz;
6918 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
6919 sound_dlg[20].d2 = pan_style;
6920
6921 int32_t ret = do_zqdialog(sound_dlg,1);
6922
6923 if(ret==2)
6924 {
6925 master_volume(digi_volume,midi_volume);
6926 if (zcmusic)
6927 zcmusic_set_volume(zcmusic, emusic_volume);
6928
6929 int32_t temp_volume = sfx_volume;
6930 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
6931 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
6932 for(int32_t i=0; i<WAV_COUNT; ++i)
6933 {
6934 //allegro assertion fails when passing in -1 as voice -DD
6935 if(sfx_voice[i] > 0)
6936 voice_set_volume(sfx_voice[i], temp_volume);
6937 }
6938 zc_set_config(sfx_sect,"digi",digi_volume);
6939 zc_set_config(sfx_sect,"midi",midi_volume);
6940 zc_set_config(sfx_sect,"sfx",sfx_volume);
6941 zc_set_config(sfx_sect,"emusic",emusic_volume);
6942 zc_set_config(sfx_sect,"pan",pan_style);
6943 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
6944 }
6945 else
6946 {
6947 midi_volume = m;
6948 digi_volume = d;
6949 emusic_volume = e;
6950 zcmusic_bufsz = b;
6951 sfx_volume = s;
6952 pan_style = p;
6953 }
6954
6955 return D_O_K;
6956 }
6957
6958 int32_t queding(char const* s1, char const* s2, char const* s3)
6959 {
6960 return jwin_alert("ZQuest Classic",s1,s2,s3,"&Yes","&No",'y','n',get_zc_font(font_lfont));
6961 }
6962
6963 int32_t onQuit()
6964 {
6965 if(Playing)
6966 {
6967 int32_t ret=0;
6968
6969 if(get_qr(qr_NOCONTINUE))
6970 {
6971 if(standalone_mode)
6972 {
6973 ret=queding("End current game?",
6974 "The continue screen is disabled; the game",
6975 "will be reloaded from the last save.");
6976 }
6977 else
6978 {
6979 ret=queding("End current game?",
6980 "The continue screen is disabled. You will",
6981 "be returned to the file select screen.");
6982 }
6983 }
6984 else
6985 ret=queding("End current game?",NULL,NULL);
6986
6987 if(ret==1)
6988 {
6989 disableClickToFreeze=false;
6990 Quit=qQUIT;
6991
6992 // Trying to evade a door repair charge?
6993 if(repaircharge)
6994 {
6995 game->change_drupy(-repaircharge);
6996 repaircharge=0;
6997 }
6998
6999 return D_CLOSE;
7000 }
7001 }
7002
7003 return D_O_K;
7004 }
7005
7006 int32_t onTryQuitMenu()
7007 {
7008 return onTryQuit(true);
7009 }
7010
7011 int32_t onTryQuit(bool inMenu)
7012 {
7013 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7014 {
7015 if(active_cutscene.can_f6())
7016 {
7017 if(get_qr(qr_OLD_F6))
7018 {
7019 if(inMenu) onQuit();
7020 else /*if(!get_qr(qr_NOCONTINUE))*/ f_Quit(qQUIT);
7021 }
7022 else
7023 {
7024 disableClickToFreeze=false;
7025 GameFlags |= GAMEFLAG_TRYQUIT;
7026 }
7027 return D_CLOSE;
7028 }
7029 else active_cutscene.error();
7030 }
7031
7032 return D_O_K;
7033 }
7034
7035 int32_t onReset()
7036 {
7037 if(queding(" Reset system? ",NULL,NULL)==1)
7038 {
7039 disableClickToFreeze=false;
7040 Quit=qRESET;
7041 replay_quit();
7042 return D_CLOSE;
7043 }
7044
7045 return D_O_K;
7046 }
7047
7048 int32_t onExit()
7049 {
7050 if(queding(" Quit ZQuest Classic? ",NULL,NULL)==1)
7051 {
7052 Quit=qEXIT;
7053 return D_CLOSE;
7054 }
7055
7056 return D_O_K;
7057 }
7058
7059 int32_t onDebug()
7060 {
7061 if(debug_enabled)
7062 set_debug(!get_debug());
7063 return D_O_K;
7064 }
7065
7066 int32_t onHeartBeep()
7067 {
7068 heart_beep=!heart_beep;
7069 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7070 return D_O_K;
7071 }
7072
7073 int32_t onSaveIndicator()
7074 {
7075 use_save_indicator = use_save_indicator ? 0 : 1;
7076 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7077 return D_O_K;
7078 }
7079
7080 int32_t onEpilepsy()
7081 {
7082 if(jwin_alert3(
7083 "Epilepsy Flash Reduction",
7084 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7085 "Disabling this will restore standard flash and wavy behaviour.",
7086 "Proceed?",
7087 "&Yes",
7088 "&No",
7089 NULL,
7090 'y',
7091 'n',
7092 0,
7093 get_zc_font(font_lfont)) == 1)
7094 {
7095 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7096 zc_set_config("zeldadx","checked_epilepsy",1);
7097 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7098 }
7099 return D_O_K;
7100 }
7101
7102 bool rc = false;
7103
7104 static DIALOG getnum_dlg[] =
7105 {
7106 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7107 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7108 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7109 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7110 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7111 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7112 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7113 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7114 };
7115
7116 int32_t getnumber(const char *prompt,int32_t initialval)
7117 {
7118 char buf[20];
7119 sprintf(buf,"%d",initialval);
7120 getnum_dlg[0].dp=(void *)prompt;
7121 getnum_dlg[0].dp2=get_zc_font(font_lfont);
7122 getnum_dlg[2].dp=buf;
7123
7124 large_dialog(getnum_dlg);
7125
7126 if(do_zqdialog(getnum_dlg,2)==3)
7127 return atoi(buf);
7128
7129 return initialval;
7130 }
7131
7132 int32_t onLife()
7133 {
7134 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7135 cheats_enqueue(Cheat::Life, value);
7136 return D_O_K;
7137 }
7138
7139 int32_t onHeartC()
7140 {
7141 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7142 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7143 cheats_enqueue(Cheat::MaxLife, max_life);
7144 cheats_enqueue(Cheat::Life, life);
7145 return D_O_K;
7146 }
7147
7148 int32_t onMagicC()
7149 {
7150 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7151 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,max_magic/game->get_mp_per_block())*game->get_mp_per_block();
7152 cheats_enqueue(Cheat::MaxMagic, max_magic);
7153 cheats_enqueue(Cheat::Magic, magic);
7154 return D_O_K;
7155 }
7156
7157 int32_t onRupies()
7158 {
7159 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7160 cheats_enqueue(Cheat::Rupies, value);
7161 return D_O_K;
7162 }
7163
7164 int32_t onMaxBombs()
7165 {
7166 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7167 cheats_enqueue(Cheat::MaxBombs, value);
7168 cheats_enqueue(Cheat::Bombs, value);
7169 return D_O_K;
7170 }
7171
7172 int32_t onRefillLife()
7173 {
7174 cheats_enqueue(Cheat::Life, game->get_maxlife());
7175 return D_O_K;
7176 }
7177 int32_t onRefillMagic()
7178 {
7179 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7180 return D_O_K;
7181 }
7182 int32_t onClock()
7183 {
7184 cheats_enqueue(Cheat::Clock);
7185 return D_O_K;
7186 }
7187
7188 int32_t onQstPath()
7189 {
7190 char path[2048];
7191
7192 chop_path(qstdir);
7193 strcpy(path,qstdir);
7194
7195 go();
7196
7197 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, get_zc_font(font_lfont)))
7198 {
7199 chop_path(path);
7200 fix_filename_case(path);
7201 fix_filename_slashes(path);
7202 strcpy(qstdir,path);
7203 strcpy(qstpath,qstdir);
7204 zc_set_config("zeldadx","quest_dir",qstdir);
7205 flush_config_file();
7206 }
7207
7208 comeback();
7209 return D_O_K;
7210 }
7211
7212 #include "dialog/cheat_dialog.h"
7213 int32_t onCheat()
7214 {
7215 call_setcheat_dialog();
7216 game->set_cheat(maxcheat);
7217 if(cheat) game->did_cheat(true);
7218 return D_O_K;
7219 }
7220
7221 int32_t onCheatRupies()
7222 {
7223 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7224 return D_O_K;
7225 }
7226
7227 int32_t onCheatArrows()
7228 {
7229 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7230 return D_O_K;
7231 }
7232
7233 int32_t onCheatBombs()
7234 {
7235 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7236 return D_O_K;
7237 }
7238
7239 // *** screen saver
7240
7241 9285900 int32_t after_time()
7242 {
7243
1/2
✓ Branch 0 taken 9285900 times.
✗ Branch 1 not taken.
9285900 if(ss_enable == 0)
7244 return INT_MAX;
7245
7246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
9285900 if(ss_after <= 0)
7247 return 5 * 60;
7248
7249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
9285900 if(ss_after <= 3)
7250 return ss_after * 15 * 60;
7251
7252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285900 times.
9285900 if(ss_after <= 13)
7253 return (ss_after - 3) * 60 * 60;
7254
7255 9285900 return MAX_IDLE + 1;
7256 9285900 }
7257
7258 static const char *after_str[15] =
7259 {
7260 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7261 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7262 "Never"
7263 };
7264
7265 const char *after_list(int32_t index, int32_t *list_size)
7266 {
7267 if(index < 0)
7268 {
7269 *list_size = 15;
7270 return NULL;
7271 }
7272
7273 return after_str[index];
7274 }
7275
7276 114 static ListData after__list(after_list, &font);
7277
7278 static DIALOG scrsaver_dlg[] =
7279 {
7280 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7281 114 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7282 114 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7283 114 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7284 114 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7285 114 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7286 114 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7287 114 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7288 114 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7289 114 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7290 114 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7291 114 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7292 114 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7293 114 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7294 };
7295
7296 int32_t onScreenSaver()
7297 {
7298 scrsaver_dlg[0].dp2=get_zc_font(font_lfont);
7299 int32_t oldcfgs[3];
7300 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7301 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7302 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7303
7304 large_dialog(scrsaver_dlg);
7305
7306 int32_t ret = do_zqdialog(scrsaver_dlg,-1);
7307
7308 if(ret == 8 || ret == 9)
7309 {
7310 ss_after = scrsaver_dlg[5].d1;
7311 ss_speed = scrsaver_dlg[6].d2;
7312 ss_density = scrsaver_dlg[7].d2;
7313 if(oldcfgs[0] != ss_after)
7314 zc_set_config(cfg_sect,"ss_after",ss_after);
7315 if(oldcfgs[1] != ss_speed)
7316 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7317 if(oldcfgs[2] != ss_density)
7318 zc_set_config(cfg_sect,"ss_density",ss_density);
7319 }
7320
7321 if(ret == 9)
7322 // preview Screen Saver
7323 {
7324 clear_keybuf();
7325 Matrix(ss_speed, ss_density, 30);
7326 system_pal(true);
7327 sys_mouse();
7328 }
7329
7330 return D_O_K;
7331 }
7332
7333 /***** Menus *****/
7334
7335 static MENU game_menu[] =
7336 {
7337 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7338 { (char *)"", NULL, NULL, 0, NULL },
7339 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7340 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7341 { (char *)"", NULL, NULL, 0, NULL },
7342 #ifdef __EMSCRIPTEN__
7343 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7344 #elif defined(ALLEGRO_MACOSX)
7345 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7346 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7347 #else
7348 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7349 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7350 #endif
7351 { NULL, NULL, NULL, 0, NULL }
7352 };
7353
7354 static MENU snapshot_format_menu[] =
7355 {
7356 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7357 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7358 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7359 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7360 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7361 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7362 { NULL, NULL, NULL, 0, NULL }
7363 };
7364
7365 static MENU controls_menu[] =
7366 {
7367 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7368 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7369 { (char *)"&Cheat Keys...", onCheatKeys, NULL, 0, NULL },
7370 { NULL, NULL, NULL, 0, NULL }
7371 };
7372
7373 static MENU name_entry_mode_menu[] =
7374 {
7375 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7376 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7377 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7378 { NULL, NULL, NULL, 0, NULL }
7379 };
7380
7381 static void set_controls_menu_active()
7382 {
7383
7384 }
7385
7386 static MENU window_menu[] =
7387 {
7388 { "Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7389 { "Lock Integer Scale", onIntegerScaling, NULL, 0, NULL },
7390 { "Save Size Changes", onSaveDragResize, NULL, 0, NULL },
7391 { "Save Position Changes", onWinPosSave, NULL, 0, NULL },
7392 { "Stretch Game Area", onStretchGame, NULL, 0, NULL },
7393 { NULL, NULL, NULL, 0, NULL }
7394 };
7395 static MENU options_menu[] =
7396 {
7397 { "Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7398 { "S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7399 { "&Window Settings", NULL, window_menu, 0, NULL },
7400 { "Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7401 { "Pause In Background", onPauseInBackground, NULL, 0, NULL },
7402 { NULL, NULL, NULL, 0, NULL }
7403 };
7404 static MENU settings_menu[] =
7405 {
7406 { "&Sound...", onSound, NULL, 0, NULL },
7407 { "C&ontrols", NULL, controls_menu, 0, NULL },
7408 { "", NULL, NULL, 0, NULL },
7409 { "Options", NULL, options_menu, 0, NULL },
7410 { "", NULL, NULL, 0, NULL },
7411 //
7412 { "&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7413 { "Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7414 { "Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7415 { "Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7416 { "Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7417 //
7418 { "Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7419 { "Volume &Keys", onVolKeys, NULL, 0, NULL },
7420 { "Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7421 { "", NULL, NULL, 0, NULL },
7422 { "Debu&g", onDebug, NULL, 0, NULL },
7423 //
7424 { NULL, NULL, NULL, 0, NULL }
7425 };
7426
7427
7428 static MENU misc_menu[] =
7429 {
7430 { (char *)"&About...", onAbout, NULL, 0, NULL },
7431 // TODO: re-enable, but: 1) do not use a bitmap thing that is hard to update 2) update names and 3) don't use the Z-word.
7432 { (char *)"&Credits...", onCredits, NULL, D_DISABLED, NULL },
7433 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7434 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7435 { (char *)"", NULL, NULL, 0, NULL },
7436 //5
7437 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7438 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7439 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7440 { (char *)"", NULL, NULL, 0, NULL },
7441 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7442 //10
7443 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7444 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7445 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7446 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7447 { (char *)"Clear Console on Qst Load", onClrConsoleOnLoad, NULL, 0, NULL },
7448 //15
7449 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7450 { NULL, NULL, NULL, 0, NULL }
7451 };
7452
7453 static MENU refill_menu[] =
7454 {
7455 { (char *)"&Life", onRefillLife, NULL, 0, NULL },
7456 { (char *)"&Magic", onRefillMagic, NULL, 0, NULL },
7457 { (char *)"&Bombs", onCheatBombs, NULL, 0, NULL },
7458 { (char *)"&Rupees", onCheatRupies, NULL, 0, NULL },
7459 { (char *)"&Arrows", onCheatArrows, NULL, 0, NULL },
7460 { NULL, NULL, NULL, 0, NULL }
7461 };
7462
7463 static MENU show_menu[] =
7464 {
7465 { (char *)"Combos", onShowLayer0, NULL, 0, NULL },
7466 { (char *)"Layer 1", onShowLayer1, NULL, 0, NULL },
7467 { (char *)"Layer 2", onShowLayer2, NULL, 0, NULL },
7468 { (char *)"Layer 3", onShowLayer3, NULL, 0, NULL },
7469 { (char *)"Layer 4", onShowLayer4, NULL, 0, NULL },
7470 { (char *)"Layer 5", onShowLayer5, NULL, 0, NULL },
7471 { (char *)"Layer 6", onShowLayer6, NULL, 0, NULL },
7472 { (char *)"Overhead Combos", onShowLayerO, NULL, 0, NULL },
7473 { (char *)"Push Blocks", onShowLayerP, NULL, 0, NULL },
7474 { (char *)"Freeform Combos", onShowLayerF, NULL, 0, NULL },
7475 { (char *)"Sprites", onShowLayerS, NULL, 0, NULL },
7476 { (char *)"", NULL, NULL, 0, NULL },
7477 { (char *)"Current FFC Scripts", onShowFFScripts, NULL, 0, NULL },
7478 { (char *)"", NULL, NULL, 0, NULL },
7479 { (char *)"Walkability", onShowLayerW, NULL, 0, NULL },
7480 { (char *)"Hitboxes", onShowHitboxes, NULL, 0, NULL },
7481 { (char *)"Effects", onShowLayerE, NULL, 0, NULL },
7482 { (char *)"Info Opacity", onShowInfoOpacity, NULL, 0, NULL },
7483 { NULL, NULL, NULL, 0, NULL }
7484 };
7485
7486 static MENU cheat_menu[] =
7487 {
7488 { (char *)"Set &Cheat", onCheat, NULL, 0, NULL },
7489 { (char *)"", NULL, NULL, 0, NULL },
7490 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7491 { (char *)"", NULL, NULL, 0, NULL },
7492 { (char *)"&Invincible", onClock, NULL, 0, NULL },
7493 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7494 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7495 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7496 { (char *)"", NULL, NULL, 0, NULL },
7497 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7498 { (char *)"", NULL, NULL, 0, NULL },
7499 { (char *)"Walk Through &Walls", onNoWalls, NULL, 0, NULL },
7500 { (char *)"Player Ignores Side&view", onIgnoreSideview, NULL, 0, NULL },
7501 { (char *)"&Quick Movement", onGoFast, NULL, 0, NULL },
7502 { (char *)"&Kill All Enemies", onKillCheat, NULL, 0, NULL },
7503 { (char *)"Trigger &Secrets", onSecretsCheat, NULL, 0, NULL },
7504 { (char *)"Trigger Secrets Perm", onSecretsCheatPerm, NULL, 0, NULL },
7505 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7506 { (char *)"Toggle &Light", onLightSwitch, NULL, 0, NULL },
7507 { (char *)"&Goto Location...", onGoTo, NULL, 0, NULL },
7508 { NULL, NULL, NULL, 0, NULL }
7509 };
7510
7511 #if DEVLEVEL > 0
7512 int32_t devLogging();
7513 int32_t devDebug();
7514 int32_t devTimestmp();
7515 #if DEVLEVEL > 1
7516 int32_t setCheat();
7517 #endif //DEVLEVEL > 1
7518 enum
7519 {
7520 dv_log,
7521 // dv_dbg,
7522 dv_tmpstmp,
7523 #if DEVLEVEL > 1
7524 dv_nil,
7525 dv_setcheat,
7526 #endif //DEVLEVEL > 1
7527 dv_max
7528 };
7529 static MENU dev_menu[] =
7530 {
7531 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7532 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7533 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7534 #if DEVLEVEL > 1
7535 { (char *)"", NULL, NULL, 0, NULL },
7536 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7537 #endif //DEVLEVEL > 1
7538 { NULL, NULL, NULL, 0, NULL }
7539 };
7540 int32_t devLogging()
7541 {
7542 dev_logging = !dev_logging;
7543 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
7544 return D_O_K;
7545 }
7546 // int32_t devDebug()
7547 // {
7548 // dev_debug = !dev_debug;
7549 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
7550 // return D_O_K;
7551 // }
7552 int32_t devTimestmp()
7553 {
7554 dev_timestmp = !dev_timestmp;
7555 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
7556 return D_O_K;
7557 }
7558 #if DEVLEVEL > 1
7559 int32_t setCheat()
7560 {
7561 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
7562 return D_O_K;
7563 }
7564 #endif //DEVLEVEL > 1
7565 #endif //DEVLEVEL > 0
7566
7567 MENU the_player_menu[] =
7568 {
7569 { (char *)"&Game", NULL, game_menu, 0, NULL },
7570 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
7571 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
7572 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7573 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
7574 #if DEVLEVEL > 0
7575 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
7576 #endif
7577 { NULL, NULL, NULL, 0, NULL }
7578 };
7579 int32_t onPauseInBackground()
7580 {
7581 if(jwin_alert3(
7582 "Toggle Pause In Background",
7583 "This action will change whether ZC Player pauses when the window loses focus.",
7584 "",
7585 "Proceed?",
7586 "&Yes",
7587 "&No",
7588 NULL,
7589 'y',
7590 'n',
7591 0,
7592 get_zc_font(font_lfont)) == 1)
7593 {
7594 pause_in_background = pause_in_background ? 0 : 1;
7595 zc_set_config("zeldadx","pause_in_background", pause_in_background);
7596 int switch_type = pause_in_background ? SWITCH_PAUSE : SWITCH_BACKGROUND;
7597 set_display_switch_mode(fullscreen?SWITCH_BACKAMNESIA:switch_type);
7598 set_display_switch_callback(SWITCH_OUT, switch_out_callback);
7599 set_display_switch_callback(SWITCH_IN, switch_in_callback);
7600 }
7601 options_menu[4].flags =(pause_in_background)?D_SELECTED:0;
7602 return D_O_K;
7603 }
7604
7605 int32_t onKeyboardEntry()
7606 {
7607 NameEntryMode=0;
7608 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7609 return D_O_K;
7610 }
7611
7612 int32_t onLetterGridEntry()
7613 {
7614 NameEntryMode=1;
7615 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7616 return D_O_K;
7617 }
7618
7619 int32_t onExtLetterGridEntry()
7620 {
7621 NameEntryMode=2;
7622 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
7623 return D_O_K;
7624 }
7625
7626 static BITMAP* oldscreen;
7627 int32_t onFullscreenMenu()
7628 {
7629 // super hacks
7630 screen = oldscreen;
7631 if (onFullscreen() == D_REDRAW)
7632 {
7633 oldscreen = screen;
7634 }
7635 screen = menu_bmp;
7636 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7637 return D_O_K;
7638 }
7639
7640 114 void fix_menu()
7641 {
7642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if(!debug_enabled)
7643 114 settings_menu[13].text = NULL;
7644 114 }
7645
7646 static DIALOG system_dlg[] =
7647 {
7648 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
7649 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
7650 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
7651 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
7652 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
7653 #ifndef ALLEGRO_MACOSX
7654 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
7655 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
7656 #else
7657 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
7658 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
7659 #endif
7660 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
7661 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
7662 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7663 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7664 };
7665
7666 void reset_snapshot_format_menu()
7667 {
7668 for(int32_t i=0; i<ssfmtMAX; ++i)
7669 {
7670 snapshot_format_menu[i].flags=0;
7671 }
7672 }
7673
7674 int32_t onSetSnapshotFormat()
7675 {
7676 switch(active_menu->text[1])
7677 {
7678 case 'B': //"&BMP"
7679 SnapshotFormat=0;
7680 break;
7681
7682 case 'G': //"&GIF"
7683 SnapshotFormat=1;
7684 break;
7685
7686 case 'J': //"&JPG"
7687 SnapshotFormat=2;
7688 break;
7689
7690 case 'P': //"&PNG"
7691 SnapshotFormat=3;
7692 break;
7693
7694 case 'C': //"PC&X"
7695 SnapshotFormat=4;
7696 break;
7697
7698 case 'T': //"&TGA"
7699 SnapshotFormat=5;
7700 break;
7701
7702 case 'L': //"&LBM"
7703 SnapshotFormat=6;
7704 break;
7705 }
7706 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
7707
7708 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
7709 return D_O_K;
7710 }
7711
7712
7713 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
7714 {
7715 PALETTE tmp;
7716
7717 for(int32_t i=0; i<256; i++)
7718 {
7719 tmp[i].r=r;
7720 tmp[i].g=g;
7721 tmp[i].b=b;
7722 }
7723
7724 fade_interpolate(src,tmp,dest,pos,from,to);
7725 }
7726
7727 14 void system_pal(bool force)
7728 {
7729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if(is_sys_pal && !force) return;
7730 14 is_sys_pal = true;
7731 14 load_colorset(gui_colorset, syspal, jwin_a5_colors);
7732 14 hw_palette = &syspal;
7733 14 update_hw_pal = true;
7734 14 }
7735
7736 static uint32_t entered_sys_pal = 0;
7737 14 void enter_sys_pal()
7738 {
7739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(is_sys_pal)
7740 {
7741 if(entered_sys_pal)
7742 ++entered_sys_pal;
7743 return;
7744 }
7745 14 sys_mouse();
7746 14 system_pal(true);
7747 14 ++entered_sys_pal;
7748 14 }
7749 14 void exit_sys_pal()
7750 {
7751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(entered_sys_pal)
7752 {
7753
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!--entered_sys_pal)
7754 {
7755 14 game_pal();
7756 14 game_mouse();
7757 14 }
7758 14 }
7759 14 }
7760
7761 void switch_out_callback()
7762 {
7763 if (pause_in_background && !MenuOpen)
7764 {
7765 System();
7766 }
7767 }
7768
7769 void switch_in_callback()
7770 {
7771 }
7772
7773 421 void game_pal()
7774 {
7775 421 is_sys_pal = false;
7776 421 entered_sys_pal = 0;
7777 421 hw_palette = &RAMpal;
7778 421 update_hw_pal = true;
7779 421 }
7780
7781 static char bar_str[] = "";
7782
7783 14 void music_pause()
7784 {
7785 //al_pause_duh(tmplayer);
7786 14 zcmusic_pause(zcmusic, ZCM_PAUSE);
7787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(zcmixer->oldtrack)
7788 zcmusic_pause(zcmixer->oldtrack, ZCM_PAUSE);
7789 14 zc_midi_pause();
7790 14 }
7791
7792 void music_resume()
7793 {
7794 //al_resume_duh(tmplayer);
7795 zcmusic_pause(zcmusic, ZCM_RESUME);
7796 if (zcmixer->oldtrack)
7797 zcmusic_pause(zcmixer->oldtrack, ZCM_RESUME);
7798 zc_midi_resume();
7799 }
7800
7801 3358 void music_stop()
7802 {
7803 //al_stop_duh(tmplayer);
7804 //unload_duh(tmusic);
7805 //tmusic=NULL;
7806 //tmplayer=NULL;
7807 3358 zcmusic_stop(zcmusic);
7808 3358 zcmusic_unload_file(zcmusic);
7809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3358 times.
3358 if (zcmixer->oldtrack)
7810 {
7811 zcmusic_stop(zcmixer->oldtrack);
7812 zcmusic_unload_file(zcmixer->oldtrack);
7813 }
7814 3358 zcmixer->newtrack = NULL;
7815 3358 zc_stop_midi();
7816 3358 currmidi=-1;
7817 3358 }
7818
7819 void System()
7820 {
7821 mouse_down=gui_mouse_b();
7822 music_pause();
7823 pause_all_sfx();
7824 MenuOpen = true;
7825 enter_sys_pal();
7826 // FONT *oldfont=font;
7827 // font=tfont;
7828
7829 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
7830 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
7831
7832 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
7833 #if DEVLEVEL > 1
7834 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
7835 #endif
7836 game_menu[3].flags =
7837 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
7838 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
7839 clear_keybuf();
7840
7841 DIALOG_PLAYER *p;
7842
7843 clear_bitmap(menu_bmp);
7844 oldscreen = screen;
7845 screen = menu_bmp;
7846
7847 p = init_dialog(system_dlg,-1);
7848
7849 // drop the menu on startup if menu button pressed
7850 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
7851 simulate_keypress(KEY_G << 8);
7852
7853 do
7854 {
7855 if(handle_close_btn_quit())
7856 break;
7857
7858 rest(17);
7859
7860 if(mouse_down && !gui_mouse_b())
7861 mouse_down=0;
7862
7863 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
7864 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
7865 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
7866 settings_menu[7].flags = ClickToFreeze?D_SELECTED:0;
7867 settings_menu[9].flags = TransLayers?D_SELECTED:0;
7868 settings_menu[10].flags = NESquit?D_SELECTED:0;
7869 settings_menu[11].flags = volkeys?D_SELECTED:0;
7870
7871 window_menu[0].flags = DragAspect?D_SELECTED:0;
7872 window_menu[1].flags = scaleForceInteger?D_SELECTED:0;
7873 window_menu[2].flags = SaveDragResize?D_SELECTED:0;
7874 window_menu[3].flags = SaveWinPos?D_SELECTED:0;
7875 window_menu[4].flags = stretchGame?D_SELECTED:0;
7876
7877 options_menu[3].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
7878 options_menu[4].flags = (pause_in_background)?D_SELECTED:0;
7879
7880 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
7881 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
7882 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
7883
7884 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
7885 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
7886 misc_menu[14].flags =(clearConsoleOnLoad)?D_SELECTED:0;
7887
7888 bool nocheat = (replay_is_replaying() || !Playing
7889 || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode && !devpwd()));
7890 the_player_menu[2].flags = nocheat ? D_DISABLED : 0;
7891 cheat_menu[0].flags = 0;
7892 refill_menu[4].flags = get_qr(qr_TRUEARROWS) ? 0 : D_DISABLED;
7893 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
7894 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
7895 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
7896 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
7897 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
7898 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
7899 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
7900 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
7901
7902 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
7903 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
7904 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
7905 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
7906 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
7907 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
7908 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
7909 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
7910 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
7911 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
7912 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
7913 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
7914 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
7915 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
7916 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
7917
7918 settings_menu[8].flags = heart_beep ? D_SELECTED : 0;
7919 settings_menu[12].flags = use_save_indicator ? D_SELECTED : 0;
7920
7921 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
7922 (char *)"Disable recording new saves" :
7923 (char *)"Enable recording new saves";
7924 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
7925 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
7926 (char *)"Stop recording" :
7927 (char *)"Stop replaying";
7928 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
7929 replay_menu[6].text = replay_is_snapshot_all_frames() ?
7930 (char *)"Disable snapshot all frames" :
7931 (char *)"Enable snapshot all frames";
7932
7933 reset_snapshot_format_menu();
7934 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
7935
7936 if(debug_enabled)
7937 {
7938 settings_menu[14].flags = get_debug() ? D_SELECTED : 0;
7939 }
7940
7941 if(gui_mouse_b() && !mouse_down)
7942 break;
7943
7944 // press menu to drop the menu
7945 if(rMbtn())
7946 simulate_keypress(KEY_G << 8);
7947
7948 if(input_idle(true) > after_time())
7949 // run Screeen Saver
7950 {
7951 // Screen saver enabled for now.
7952 clear_keybuf();
7953 Matrix(ss_speed, ss_density, 0);
7954 system_pal(true);
7955 sys_mouse();
7956 broadcast_dialog_message(MSG_DRAW, 0);
7957 }
7958
7959 update_hw_screen();
7960 }
7961 while(update_dialog(p));
7962
7963 screen = oldscreen;
7964
7965 // font=oldfont;
7966 mouse_down=gui_mouse_b();
7967 shutdown_dialog(p);
7968 MenuOpen = false;
7969 if(Quit)
7970 {
7971 kill_sfx();
7972 music_stop();
7973 update_hw_screen();
7974 }
7975 else
7976 {
7977 music_resume();
7978 resume_all_sfx();
7979
7980 if(rc)
7981 ringcolor(false);
7982 }
7983 exit_sys_pal();
7984
7985 eat_buttons();
7986
7987 rc=false;
7988 clear_keybuf();
7989
7990 zc_init_apply_cheat_delta();
7991 }
7992
7993 114 void fix_dialogs()
7994 {
7995 114 jwin_center_dialog(about_dlg);
7996 114 jwin_center_dialog(gamepad_dlg);
7997 114 jwin_center_dialog(credits_dlg);
7998 114 jwin_center_dialog(gamemode_dlg);
7999 114 jwin_center_dialog(getnum_dlg);
8000 114 jwin_center_dialog(goto_dlg);
8001 114 jwin_center_dialog(keyboard_control_dlg);
8002 114 jwin_center_dialog(midi_dlg);
8003 114 jwin_center_dialog(quest_dlg);
8004 114 jwin_center_dialog(scrsaver_dlg);
8005 114 jwin_center_dialog(sound_dlg);
8006 114 jwin_center_dialog(triforce_dlg);
8007
8008 // digi_dp[1] += scrx;
8009 // digi_dp[2] += scry;
8010 // midi_dp[1] += scrx;
8011 // midi_dp[2] += scry;
8012 // pan_dp[1] += scrx;
8013 // pan_dp[2] += scry;
8014 // emus_dp[1] += scrx;
8015 // emus_dp[2] += scry;
8016 // buf_dp[1] += scrx;
8017 // buf_dp[2] += scry;
8018 // sfx_dp[1] += scrx;
8019 // sfx_dp[2] += scry;
8020 114 }
8021
8022 /*****************************/
8023 /**** Custom Sound System ****/
8024 /*****************************/
8025
8026 114 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8027 {
8028
2/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
114 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8029 }
8030
8031 // Run an NSF, or a MIDI if the NSF is missing somehow.
8032 149 bool try_zcmusic(const char *filename, int32_t track, int32_t midi, int32_t fadeoutframes)
8033 {
8034 149 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8035
8036 // Found it
8037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(newzcmusic!=NULL)
8038 {
8039 newzcmusic->fadevolume = 10000;
8040 newzcmusic->fadeoutframes = fadeoutframes;
8041
8042 zcmixer->newtrack = newzcmusic;
8043
8044 zcmusic_stop(zcmusic);
8045 zcmusic_unload_file(zcmusic);
8046 zc_stop_midi();
8047
8048 zcmusic=newzcmusic;
8049 int32_t temp_volume = emusic_volume;
8050 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8051 temp_volume = (emusic_volume * FFCore.usr_music_volume) / 10000 / 100;
8052 temp_volume = (temp_volume * zcmusic->fadevolume) / 10000;
8053 zcmusic_play(zcmusic, temp_volume);
8054
8055 if(track>0)
8056 zcmusic_change_track(zcmusic,track);
8057
8058 return true;
8059 }
8060
8061 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8062
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 70 times.
149 else if(midi>-1000)
8063 70 jukebox(midi);
8064
8065 149 return false;
8066 149 }
8067
8068 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8069 {
8070 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8071 // Found it
8072 if(newzcmusic!=NULL)
8073 {
8074 zcmusic_stop(zcmusic);
8075 zcmusic_unload_file(zcmusic);
8076 zc_stop_midi();
8077
8078 zcmusic=newzcmusic;
8079 zcmusic_play(zcmusic, emusic_volume);
8080
8081 if(track>0)
8082 zcmusic_change_track(zcmusic,track);
8083
8084 return true;
8085 }
8086
8087 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8088 else if(midi>-1000)
8089 jukebox(midi);
8090
8091 return false;
8092 }
8093
8094 int32_t get_zcmusicpos()
8095 {
8096 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8097 return debugtracething;
8098 return 0;
8099 }
8100
8101 void set_zcmusicpos(int32_t position)
8102 {
8103 zcmusic_set_curpos(zcmusic, position);
8104 }
8105
8106 void set_zcmusicspeed(int32_t speed)
8107 {
8108 zcmusic_set_speed(zcmusic, speed);
8109 }
8110
8111 int32_t get_zcmusiclen()
8112 {
8113 return zcmusic_get_length(zcmusic);
8114 }
8115
8116 void set_zcmusicloop(double start, double end)
8117 {
8118 zcmusic_set_loop(zcmusic, start, end);
8119 }
8120
8121 63941 void jukebox(int32_t index,int32_t loop)
8122 {
8123
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if (is_headless())
8124 63941 return;
8125
8126 music_stop();
8127
8128 if(index<0) index=MAXMIDIS-1;
8129
8130 if(index>=MAXMIDIS) index=0;
8131
8132 music_stop();
8133
8134 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8135 // stuck notes when a song stops. This fixes it.
8136 if(strcmp(midi_driver->name, "DIGMID")==0)
8137 zc_set_volume(0, 0);
8138
8139 zc_set_volume(-1, mixvol(tunes[index].volume, midi_volume >>1));
8140 zc_play_midi((MIDI*)tunes[index].data,loop);
8141
8142 if(tunes[index].start>0)
8143 zc_midi_seek(tunes[index].start);
8144
8145 midi_loop_start = tunes[index].loop_start;
8146 midi_loop_end = tunes[index].loop_end;
8147
8148 currmidi=index;
8149 master_volume(digi_volume, midi_volume);
8150 //midi_paused=false;
8151 63941 }
8152
8153 63941 void jukebox(int32_t index)
8154 {
8155
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index<0) index=MAXMIDIS-1;
8156
8157
1/2
✓ Branch 0 taken 63941 times.
✗ Branch 1 not taken.
63941 if(index>=MAXMIDIS) index=0;
8158
8159 // do nothing if it's already playing
8160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63941 if(index==currmidi && midi_pos>=0)
8161 {
8162 return;
8163 }
8164
8165 63941 jukebox(index,tunes[index].loop);
8166 63941 }
8167
8168 16 void play_DmapMusic()
8169 {
8170
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if (is_headless())
8171 16 return;
8172
8173 static char tfile[2048];
8174 static int32_t ttrack=0;
8175 bool domidi=false;
8176
8177 int32_t fadeoutframes = 0;
8178 if (zcmusic != NULL)
8179 fadeoutframes = zcmusic->fadeoutframes;
8180
8181 if(DMaps[currdmap].tmusic[0]!=0)
8182 {
8183 if(zcmusic==NULL ||
8184 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8185 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8186 {
8187 if (DMaps[currdmap].tmusic_xfade_in > 0 || fadeoutframes > 0)
8188 {
8189 if (FFCore.play_enh_music_crossfade(DMaps[currdmap].tmusic, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes))
8190 {
8191 if (zcmusic != NULL)
8192 {
8193 zcmusic->fadeoutframes = DMaps[currdmap].tmusic_xfade_out;
8194 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8195 }
8196 }
8197 }
8198 else
8199 {
8200 if (zcmusic != NULL)
8201 {
8202 zcmusic_stop(zcmusic);
8203 zcmusic_unload_file(zcmusic);
8204 zcmusic = NULL;
8205 zcmixer->newtrack = NULL;
8206 }
8207
8208 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8209 zcmixer->newtrack = zcmusic;
8210
8211 if (zcmusic != NULL)
8212 {
8213 zc_stop_midi();
8214 strcpy(tfile, DMaps[currdmap].tmusic);
8215 zcmusic_play(zcmusic, emusic_volume);
8216 int32_t temptracks = 0;
8217 temptracks = zcmusic_get_tracks(zcmusic);
8218 temptracks = (temptracks < 2) ? 1 : temptracks;
8219 ttrack = vbound(DMaps[currdmap].tmusictrack, 0, temptracks - 1);
8220 zcmusic_change_track(zcmusic, ttrack);
8221 zcmusic_set_loop(zcmusic, double(DMaps[currdmap].tmusic_loop_start / 10000.0), double(DMaps[currdmap].tmusic_loop_end / 10000.0));
8222 }
8223 else
8224 {
8225 tfile[0] = 0;
8226 domidi = true;
8227 }
8228 }
8229 }
8230 }
8231 else
8232 {
8233 if (DMaps[currdmap].midi == 0 && fadeoutframes > 0 && zcmusic != NULL && strcmp(zcmusic->filename, DMaps[currdmap].tmusic) != 0)
8234 {
8235 FFCore.play_enh_music_crossfade(NULL, DMaps[currdmap].tmusictrack, DMaps[currdmap].tmusic_xfade_in, fadeoutframes);
8236 }
8237 else
8238 {
8239 domidi = true;
8240 }
8241 }
8242
8243 if(domidi)
8244 {
8245 int32_t m=DMaps[currdmap].midi;
8246
8247 switch(m)
8248 {
8249 case 1:
8250 jukebox(ZC_MIDI_OVERWORLD);
8251 break;
8252
8253 case 2:
8254 jukebox(ZC_MIDI_DUNGEON);
8255 break;
8256
8257 case 3:
8258 jukebox(ZC_MIDI_LEVEL9);
8259 break;
8260
8261 default:
8262 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8263 jukebox(m+MIDIOFFSET_DMAP);
8264 else
8265 music_stop();
8266 }
8267 }
8268 16 }
8269
8270 15752 void playLevelMusic()
8271 {
8272
1/2
✓ Branch 0 taken 15752 times.
✗ Branch 1 not taken.
15752 if (is_headless())
8273 15752 return;
8274
8275 int32_t m=tmpscr->screen_midi;
8276
8277 switch(m)
8278 {
8279 case -2:
8280 music_stop();
8281 break;
8282
8283 case -1:
8284 play_DmapMusic();
8285 break;
8286
8287 case 1:
8288 jukebox(ZC_MIDI_OVERWORLD);
8289 break;
8290
8291 case 2:
8292 jukebox(ZC_MIDI_DUNGEON);
8293 break;
8294
8295 case 3:
8296 jukebox(ZC_MIDI_LEVEL9);
8297 break;
8298
8299 default:
8300 if(m>=4 && m<4+MAXCUSTOMMIDIS)
8301 jukebox(m+MIDIOFFSET_MAPSCR);
8302 else
8303 music_stop();
8304 }
8305 15752 }
8306
8307 114 void master_volume(int32_t dv,int32_t mv)
8308 {
8309
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
114 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
8310
8311
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 114 times.
✗ Branch 7 not taken.
114 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
8312
8313
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 114 times.
114 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
8314 114 int32_t temp_vol = midi_volume;
8315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!get_qr(qr_OLD_SCRIPT_VOLUME))
8316 114 temp_vol = (midi_volume * FFCore.usr_music_volume) / 10000 / 100;
8317 114 zc_set_volume(digi_volume,mixvol(tunes[i].volume, temp_vol));
8318 114 }
8319
8320 /*****************/
8321 /***** SFX *****/
8322 /*****************/
8323
8324 // array of voices, one for each sfx sample in the data file
8325 // 0+ = voice #
8326 // -1 = voice not allocated
8327 114 void Z_init_sound()
8328 {
8329
2/2
✓ Branch 0 taken 29184 times.
✓ Branch 1 taken 114 times.
29298 for(int32_t i=0; i<WAV_COUNT; i++)
8330 29184 sfx_voice[i]=-1;
8331
8332 114 const char* midis[ZC_MIDI_COUNT] = {
8333 "assets/dungeon.mid",
8334 "assets/ending.mid",
8335 "assets/gameover.mid",
8336 "assets/level9.mid",
8337 "assets/overworld.mid",
8338 "assets/title.mid",
8339 "assets/triforce.mid",
8340 };
8341
2/2
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 114 times.
912 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
8342 {
8343 798 tunes[i].data = load_midi(midis[i]);
8344
1/2
✓ Branch 0 taken 798 times.
✗ Branch 1 not taken.
798 if (!tunes[i].data)
8345 Z_error_fatal("Missing required file %s\n", midis[i]);
8346 798 }
8347
8348
2/2
✓ Branch 0 taken 28728 times.
✓ Branch 1 taken 114 times.
28842 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
8349 28728 tunes[ZC_MIDI_COUNT+j].data=NULL;
8350
8351 114 master_volume(digi_volume,midi_volume);
8352 114 }
8353
8354 // returns number of voices currently allocated
8355 int32_t sfx_count()
8356 {
8357 int32_t c=0;
8358
8359 for(int32_t i=0; i<WAV_COUNT; i++)
8360 if(sfx_voice[i]!=-1)
8361 ++c;
8362
8363 return c;
8364 }
8365
8366 // clean up finished samples
8367 9217156 void sfx_cleanup()
8368 {
8369
2/2
✓ Branch 0 taken 2359591936 times.
✓ Branch 1 taken 9217156 times.
2368809092 for(int32_t i=0; i<WAV_COUNT; i++)
8370
3/4
✓ Branch 0 taken 619761 times.
✓ Branch 1 taken 2358972175 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 619761 times.
2360211697 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
8371 {
8372 619761 deallocate_voice(sfx_voice[i]);
8373 619761 sfx_voice[i]=-1;
8374 619761 }
8375 9217156 }
8376
8377 // allocates a voice for the sample "wav_index" (index into zelda.dat)
8378 // if a voice is already allocated (and/or playing), then it just returns true
8379 // Returns true: voice is allocated
8380 // false: unsuccessful
8381 964178 bool sfx_init(int32_t index)
8382 {
8383 // check index
8384
3/4
✓ Branch 0 taken 721789 times.
✓ Branch 1 taken 242389 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 721789 times.
964178 if(index<=0 || index>=WAV_COUNT)
8385 242389 return false;
8386
8387
2/2
✓ Branch 0 taken 102010 times.
✓ Branch 1 taken 619779 times.
721789 if(sfx_voice[index]==-1)
8388 {
8389
2/2
✓ Branch 0 taken 209876 times.
✓ Branch 1 taken 409903 times.
619779 if(sfxdat)
8390 {
8391
1/2
✓ Branch 0 taken 209876 times.
✗ Branch 1 not taken.
209876 if(index<Z35)
8392 {
8393 209876 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
8394 209876 }
8395 else
8396 {
8397 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
8398 }
8399 209876 }
8400 else
8401 {
8402 409903 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
8403 }
8404
8405 619779 int32_t temp_volume = sfx_volume;
8406
2/4
✓ Branch 0 taken 619779 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 619779 times.
✗ Branch 3 not taken.
619779 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8407 temp_volume = (sfx_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8408 619779 voice_set_volume(sfx_voice[index], temp_volume);
8409 619779 }
8410
8411 721789 return sfx_voice[index] != -1;
8412 964178 }
8413
8414 int32_t sfx_get_default_freq(int32_t index)
8415 {
8416 if (sfxdat)
8417 {
8418 if (index < Z35)
8419 {
8420 return ((SAMPLE*)sfxdata[index].dat)->freq;
8421 }
8422 else
8423 {
8424 return ((SAMPLE*)sfxdata[Z35].dat)->freq;
8425 }
8426 }
8427 else
8428 {
8429 return customsfxdata[index].freq;
8430 }
8431 }
8432
8433 int32_t sfx_get_length(int32_t index)
8434 {
8435 if (sfxdat)
8436 {
8437 if (index < Z35)
8438 {
8439 return int32_t(((SAMPLE*)sfxdata[index].dat)->len);
8440 }
8441 else
8442 {
8443 return int32_t(((SAMPLE*)sfxdata[Z35].dat)->len);
8444 }
8445 }
8446 else
8447 {
8448 return int32_t(customsfxdata[index].len);
8449 }
8450 }
8451
8452 // plays an sfx sample
8453 964178 void sfx(int32_t index,int32_t pan,bool loop, bool restart, int32_t vol, int32_t freq)
8454 {
8455
2/2
✓ Branch 0 taken 721789 times.
✓ Branch 1 taken 242389 times.
964178 if(!sfx_init(index))
8456 242389 return;
8457
1/2
✓ Branch 0 taken 721789 times.
✗ Branch 1 not taken.
721789 if (!is_headless())
8458 {
8459 voice_set_playmode(sfx_voice[index], loop ? PLAYMODE_LOOP : PLAYMODE_PLAY);
8460 voice_set_pan(sfx_voice[index], pan);
8461
8462 // Only used by ZScript currently
8463 if (freq <= -1)
8464 {
8465 freq = sfx_get_default_freq(index);
8466 }
8467 voice_set_frequency(sfx_voice[index], freq);
8468
8469 // Only used by ZScript currently
8470 int32_t temp_volume = (sfx_volume * vol) / 10000 / 100;
8471 if (GameLoaded && !get_qr(qr_OLD_SCRIPT_VOLUME))
8472 temp_volume = (temp_volume * FFCore.usr_sfx_volume) / 10000 / 100;
8473 voice_set_volume(sfx_voice[index], temp_volume);
8474
8475 int32_t pos = voice_get_position(sfx_voice[index]);
8476
8477 if (restart) voice_set_position(sfx_voice[index], 0);
8478
8479 if (pos <= 0)
8480 voice_start(sfx_voice[index]);
8481 }
8482
8483
3/4
✓ Branch 0 taken 397998 times.
✓ Branch 1 taken 323791 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 397998 times.
721789 if (restart && replay_is_debug())
8484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 397998 times.
397998 replay_step_comment(fmt::format("sfx {}", sfx_string[index]));
8485 964178 }
8486
8487 // true if sfx is allocated
8488 68052 bool sfx_allocated(int32_t index)
8489 {
8490
3/4
✓ Branch 0 taken 9923 times.
✓ Branch 1 taken 58129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9923 times.
68052 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
8491 }
8492
8493 // start it (in loop mode) if it's not already playing,
8494 // otherwise adjust it to play in loop mode -DD
8495 55171 void cont_sfx(int32_t index)
8496 {
8497
1/2
✓ Branch 0 taken 55171 times.
✗ Branch 1 not taken.
55171 if (is_headless())
8498 55171 return;
8499
8500 if(!sfx_init(index))
8501 {
8502 return;
8503 }
8504
8505 if(voice_get_position(sfx_voice[index])<=0)
8506 {
8507 voice_set_position(sfx_voice[index],0);
8508 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
8509 voice_start(sfx_voice[index]);
8510 }
8511 else
8512 {
8513 adjust_sfx(index, 128, true);
8514 }
8515 55171 }
8516
8517 // adjust parameters while playing
8518 4075 void adjust_sfx(int32_t index,int32_t pan,bool loop)
8519 {
8520
4/6
✓ Branch 0 taken 2315 times.
✓ Branch 1 taken 1760 times.
✓ Branch 2 taken 2315 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2315 times.
4075 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
8521 4075 return;
8522
8523 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
8524 voice_set_pan(sfx_voice[index],pan);
8525 4075 }
8526
8527 // pauses a voice
8528 1725 void pause_sfx(int32_t index)
8529 {
8530
3/6
✓ Branch 0 taken 1725 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1725 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1725 times.
1725 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8531 voice_stop(sfx_voice[index]);
8532 1725 }
8533
8534 // resumes a voice
8535 747 void resume_sfx(int32_t index)
8536 {
8537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 747 times.
747 if (is_headless())
8538 747 return;
8539
8540 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
8541 voice_start(sfx_voice[index]);
8542 747 }
8543
8544 // pauses all active voices
8545 452 void pause_all_sfx()
8546 {
8547
2/2
✓ Branch 0 taken 115712 times.
✓ Branch 1 taken 452 times.
116164 for(int32_t i=0; i<WAV_COUNT; i++)
8548
2/2
✓ Branch 0 taken 115711 times.
✓ Branch 1 taken 1 times.
115713 if(sfx_voice[i]!=-1)
8549 1 voice_stop(sfx_voice[i]);
8550 452 }
8551
8552 // resumes all paused voices
8553 438 void resume_all_sfx()
8554 {
8555
2/2
✓ Branch 0 taken 112128 times.
✓ Branch 1 taken 438 times.
112566 for(int32_t i=0; i<WAV_COUNT; i++)
8556
1/2
✓ Branch 0 taken 112128 times.
✗ Branch 1 not taken.
112128 if(sfx_voice[i]!=-1)
8557 voice_start(sfx_voice[i]);
8558 438 }
8559
8560 // stops an sfx and deallocates the voice
8561 7461547 void stop_sfx(int32_t index)
8562 {
8563
3/4
✓ Branch 0 taken 6276481 times.
✓ Branch 1 taken 1185066 times.
✓ Branch 2 taken 6276481 times.
✗ Branch 3 not taken.
7461547 if(index<=0 || index>=WAV_COUNT)
8564 1185066 return;
8565
8566
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6276469 times.
6276481 if(sfx_voice[index]!=-1)
8567 {
8568 12 deallocate_voice(sfx_voice[index]);
8569 12 sfx_voice[index]=-1;
8570 12 }
8571 7461547 }
8572
8573 // Stops SFX played by Hero's item of the given family
8574 128638 void stop_item_sfx(int32_t family)
8575 {
8576 128638 int32_t id=current_item_id(family);
8577
8578
2/2
✓ Branch 0 taken 128083 times.
✓ Branch 1 taken 555 times.
128638 if(id<0)
8579 128083 return;
8580
8581 555 stop_sfx(itemsbuf[id].usesound);
8582 128638 }
8583
8584 3220 void kill_sfx()
8585 {
8586
2/2
✓ Branch 0 taken 824320 times.
✓ Branch 1 taken 3220 times.
827540 for(int32_t i=0; i<WAV_COUNT; i++)
8587
2/2
✓ Branch 0 taken 824314 times.
✓ Branch 1 taken 6 times.
824326 if(sfx_voice[i]!=-1)
8588 {
8589 6 deallocate_voice(sfx_voice[i]);
8590 6 sfx_voice[i]=-1;
8591 6 }
8592 3220 }
8593
8594 659811 int32_t pan(int32_t x)
8595 {
8596
1/4
✓ Branch 0 taken 659811 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
659811 switch(pan_style)
8597 {
8598 case 0:
8599 return 128;
8600
8601 case 1:
8602 659811 return vbound((x>>1)+68,0,255);
8603
8604 case 2:
8605 return vbound(((x*3)>>2)+36,0,255);
8606 }
8607
8608 return vbound(x,0,255);
8609 659811 }
8610
8611 /*******************************/
8612 /******* Input Handlers ********/
8613 /*******************************/
8614
8615 25089976 bool joybtn(int32_t b)
8616 {
8617
1/2
✓ Branch 0 taken 25089976 times.
✗ Branch 1 not taken.
25089976 if(b == 0)
8618 return false;
8619
1/2
✓ Branch 0 taken 25089976 times.
✗ Branch 1 not taken.
25089976 if (b-1 >= joy[joystick_index].num_buttons)
8620 25089976 return false;
8621
8622 return joy[joystick_index].button[b-1].b !=0;
8623 25089976 }
8624
8625 bool joystick(int32_t s)
8626 {
8627 if(s < 0)
8628 return false;
8629 if (s >= joy[joystick_index].num_sticks)
8630 return false;
8631
8632 for (int i = 0; i < joy[joystick_index].stick[s].num_axis; i++)
8633 {
8634 if (joy[joystick_index].stick[s].axis[i].d1 || joy[joystick_index].stick[s].axis[i].d2)
8635 return true;
8636 }
8637 return false;
8638 }
8639
8640 const char* joybtn_name(int32_t b)
8641 {
8642 if (b <= 0 || b > joy[joystick_index].num_buttons)
8643 return "";
8644
8645 return joy[joystick_index].button[b-1].name;
8646 }
8647
8648 const char* joystick_name(int32_t s)
8649 {
8650 if (s < 0 || s >= joy[joystick_index].num_sticks)
8651 return "";
8652
8653 return joy[joystick_index].stick[s].name;
8654 }
8655
8656 int32_t next_press_key();
8657
8658 int32_t next_joy_input(bool buttons)
8659 {
8660 clear_keybuf();
8661
8662 //first, we need to wait until they're pressing no buttons
8663 for(;;)
8664 {
8665 if(keypressed())
8666 {
8667 switch(readkey()>>8)
8668 {
8669 case KEY_ESC:
8670 return -1;
8671
8672 case KEY_SPACE:
8673 return 0;
8674 }
8675 }
8676
8677 poll_joystick();
8678 bool done = true;
8679
8680 if (buttons)
8681 {
8682 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8683 {
8684 if(joybtn(i)) done = false;
8685 }
8686 }
8687 else
8688 {
8689 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8690 {
8691 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8692 return -2;
8693 }
8694 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8695 {
8696 if(joystick(i)) done = false;
8697 }
8698 }
8699
8700 if(done) break;
8701 rest(1);
8702 }
8703
8704 //now, we need to wait for them to press any button
8705 for(;;)
8706 {
8707 if(keypressed())
8708 {
8709 switch(readkey()>>8)
8710 {
8711 case KEY_ESC:
8712 return -1;
8713
8714 case KEY_SPACE:
8715 return 0;
8716 }
8717 }
8718
8719 poll_joystick();
8720
8721 if (buttons)
8722 {
8723 if (!gamepad_dlg_cur_joystick || !al_get_joystick_active(gamepad_dlg_cur_joystick))
8724 {
8725 InfoDialog("ZC", "Invalid gamepad. Did it disconnect?").show();
8726 return -2;
8727 }
8728 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
8729 {
8730 if(joybtn(i))
8731 return i;
8732 }
8733 }
8734 else
8735 {
8736 for(int32_t i=0; i<joy[joystick_index].num_sticks; i++)
8737 {
8738 if(joystick(i))
8739 return i;
8740 }
8741 }
8742 rest(1);
8743 }
8744 }
8745
8746 1201117 static bool rButton(bool &btn, bool &flag, bool rawbtn)
8747 {
8748
2/2
✓ Branch 0 taken 1196766 times.
✓ Branch 1 taken 4351 times.
1201117 bool ret = btn && !flag;
8749 1201117 flag = rawbtn;
8750
8751 1201117 return ret;
8752 }
8753 190785676 static bool rButton(bool &btn, bool &flag)
8754 {
8755
2/2
✓ Branch 0 taken 183942299 times.
✓ Branch 1 taken 6843377 times.
190785676 bool ret = btn && !flag;
8756 190785676 flag = btn;
8757
8758 190785676 return ret;
8759 }
8760 2888985 static bool rButtonPeek(bool btn, bool flag)
8761 {
8762
2/2
✓ Branch 0 taken 2685887 times.
✓ Branch 1 taken 203098 times.
2888985 if(!btn)
8763 {
8764 2685887 return false;
8765 }
8766
2/2
✓ Branch 0 taken 17939 times.
✓ Branch 1 taken 185159 times.
203098 else if(!flag)
8767 {
8768 17939 return true;
8769 }
8770
8771 185159 return false;
8772 2888985 }
8773
8774 // Updated only by keyboard/gamepad.
8775 // If in replay mode, this is set directly by the replay system.
8776 // This should never be read from directly - use control_state instead.
8777 bool raw_control_state[ZC_CONTROL_STATES];
8778
8779 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
8780 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
8781 // lasts until the next call to load_control_state.
8782 bool control_state[ZC_CONTROL_STATES];
8783 bool disable_control[ZC_CONTROL_STATES];
8784 bool drunk_toggle_state[11];
8785 bool disabledKeys[127];
8786 bool KeyInput[127];
8787 bool KeyPress[127];
8788
8789 bool key_current_frame[127];
8790 bool key_previous_frame[127];
8791
8792 static bool key_system[127];
8793 static bool key_system_previous[127];
8794 static bool key_system_press[127];
8795
8796 bool button_press[ZC_CONTROL_STATES];
8797 bool button_hold[ZC_CONTROL_STATES];
8798
8799 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
8800 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
8801 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
8802 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
8803 #define STICK_PRECISION 56 //define your own sensitivity
8804
8805 7800063 void load_control_state()
8806 {
8807 7800063 load_control_called_this_frame = true;
8808
8809
2/2
✓ Branch 0 taken 4832564 times.
✓ Branch 1 taken 2967499 times.
7800063 if (replay_version_check(8, 11))
8810 {
8811
2/2
✓ Branch 0 taken 53414982 times.
✓ Branch 1 taken 2967499 times.
56382481 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8812 53414982 down_control_states[i] = raw_control_state[i];
8813 2967499 }
8814
8815
1/2
✓ Branch 0 taken 7800063 times.
✗ Branch 1 not taken.
7800063 if (!replay_is_replaying())
8816 {
8817 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
8818 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
8819 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
8820 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
8821 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
8822 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
8823 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
8824 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
8825 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
8826 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
8827 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
8828 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
8829 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
8830 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
8831
8832 if(num_joysticks != 0)
8833 {
8834 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
8835 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
8836 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
8837 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
8838 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
8839 }
8840 else
8841 {
8842 raw_control_state[14] = false;
8843 raw_control_state[15] = false;
8844 raw_control_state[16] = false;
8845 raw_control_state[17] = false;
8846 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
8847 }
8848 }
8849
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 7800060 times.
7800063 if (replay_is_active())
8850 {
8851
2/2
✓ Branch 0 taken 1015215 times.
✓ Branch 1 taken 6784845 times.
7800060 if (replay_get_version() < 3)
8852 1015215 replay_poll();
8853
3/4
✓ Branch 0 taken 6784845 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5023470 times.
✓ Branch 3 taken 1761375 times.
6784845 else if (replay_is_replaying() && replay_get_version() < 6)
8854 1761375 replay_peek_input();
8855
3/4
✓ Branch 0 taken 5023470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2055971 times.
✓ Branch 3 taken 2967499 times.
5023470 else if (replay_is_replaying() && replay_version_check(8, 11))
8856 2967499 replay_peek_input();
8857
2/2
✓ Branch 0 taken 6695784 times.
✓ Branch 1 taken 1104276 times.
7800060 if (replay_get_version() == 8)
8858 1104276 update_keys();
8859 7800060 }
8860
8861 // Some test replay files were made before a serious input bug was fixed, so instead
8862 // of re-doing them or tossing them out, just check for that zplay version.
8863
3/4
✓ Branch 0 taken 7800057 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 121900 times.
✓ Branch 3 taken 7678157 times.
7800063 bool botched_input = replay_is_active() && replay_get_version() != 1 && replay_get_version() < 8;
8864
2/2
✓ Branch 0 taken 140401026 times.
✓ Branch 1 taken 7800057 times.
148201083 for (int i = 0; i < ZC_CONTROL_STATES; i++)
8865 {
8866 140401026 control_state[i] = raw_control_state[i];
8867
4/4
✓ Branch 0 taken 49487310 times.
✓ Branch 1 taken 90913716 times.
✓ Branch 2 taken 2410168 times.
✓ Branch 3 taken 47077142 times.
140401026 if (botched_input && !control_state[i])
8868 47077142 down_control_states[i] = false;
8869 140401026 }
8870 7800057 bool did_bad_cutscene_btn = false;
8871
2/2
✓ Branch 0 taken 7800057 times.
✓ Branch 1 taken 140401026 times.
148201083 for(int q = 0; q < 18; ++q)
8872
4/4
✓ Branch 0 taken 6463939 times.
✓ Branch 1 taken 133937087 times.
✓ Branch 2 taken 6463205 times.
✓ Branch 3 taken 734 times.
140401760 if(control_state[q] && !active_cutscene.can_button(q))
8873 {
8874 734 control_state[q] = false;
8875 734 did_bad_cutscene_btn = true;
8876 734 }
8877
2/2
✓ Branch 0 taken 7799542 times.
✓ Branch 1 taken 515 times.
7800057 if(did_bad_cutscene_btn)
8878 515 active_cutscene.error();
8879
8880 7800057 button_press[0]=rButton(control_state[0],button_hold[0]);
8881 7800057 button_press[1]=rButton(control_state[1],button_hold[1]);
8882 7800057 button_press[2]=rButton(control_state[2],button_hold[2]);
8883 7800057 button_press[3]=rButton(control_state[3],button_hold[3]);
8884 7800057 button_press[4]=rButton(control_state[4],button_hold[4]);
8885 7800057 button_press[5]=rButton(control_state[5],button_hold[5]);
8886 7800057 button_press[6]=rButton(control_state[6],button_hold[6]);
8887 7800057 button_press[7]=rButton(control_state[7],button_hold[7]);
8888 7800057 button_press[8]=rButton(control_state[8],button_hold[8]);
8889 7800057 button_press[9]=rButton(control_state[9],button_hold[9]);
8890 7800057 button_press[10]=rButton(control_state[10],button_hold[10]);
8891 7800057 button_press[11]=rButton(control_state[11],button_hold[11]);
8892 7800057 button_press[12]=rButton(control_state[12],button_hold[12]);
8893 7800057 button_press[13]=rButton(control_state[13],button_hold[13]);
8894 7800057 button_press[14]=rButton(control_state[14],button_hold[14]);
8895 7800057 button_press[15]=rButton(control_state[15],button_hold[15]);
8896 7800057 button_press[16]=rButton(control_state[16],button_hold[16]);
8897 7800057 button_press[17]=rButton(control_state[17],button_hold[17]);
8898 7800057 }
8899
8900 // Returns true if any game key is pressed. This is needed because keypressed()
8901 // doesn't detect modifier keys and control_state[] can be modified by scripts.
8902 40245126 bool zc_key_pressed()
8903 //may also need to use zc_getrawkey
8904 {
8905
7/10
✓ Branch 0 taken 32593346 times.
✓ Branch 1 taken 7651780 times.
✓ Branch 2 taken 7651780 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7651780 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6395524 times.
✓ Branch 7 taken 6395524 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2461351 times.
42706477 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
8906
4/6
✓ Branch 0 taken 6395524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6395524 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4843517 times.
✓ Branch 5 taken 4843517 times.
6395524 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
8907
4/6
✓ Branch 0 taken 4843517 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4843517 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3142817 times.
✓ Branch 5 taken 3142817 times.
4843517 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
8908
4/6
✓ Branch 0 taken 3142817 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3142817 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2731875 times.
✓ Branch 5 taken 2731875 times.
3142817 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
8909
1/2
✓ Branch 0 taken 2731875 times.
✗ Branch 1 not taken.
2731875 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
8910
3/4
✓ Branch 0 taken 2612468 times.
✓ Branch 1 taken 119407 times.
✓ Branch 2 taken 2612468 times.
✗ Branch 3 not taken.
2731875 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
8911
3/4
✓ Branch 0 taken 2493565 times.
✓ Branch 1 taken 118903 times.
✓ Branch 2 taken 2493565 times.
✗ Branch 3 not taken.
2612468 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
8912
3/4
✓ Branch 0 taken 2478420 times.
✓ Branch 1 taken 15145 times.
✓ Branch 2 taken 2478420 times.
✗ Branch 3 not taken.
2493565 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
8913
3/4
✓ Branch 0 taken 2464921 times.
✓ Branch 1 taken 13499 times.
✓ Branch 2 taken 2464921 times.
✗ Branch 3 not taken.
2478420 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
8914
3/4
✓ Branch 0 taken 2462427 times.
✓ Branch 1 taken 2494 times.
✓ Branch 2 taken 2462427 times.
✗ Branch 3 not taken.
2464921 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
8915
3/4
✓ Branch 0 taken 2462209 times.
✓ Branch 1 taken 218 times.
✓ Branch 2 taken 2462209 times.
✗ Branch 3 not taken.
2462427 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
8916
3/4
✓ Branch 0 taken 2461370 times.
✓ Branch 1 taken 839 times.
✓ Branch 2 taken 2461370 times.
✗ Branch 3 not taken.
2462209 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
8917
2/4
✓ Branch 0 taken 2461370 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2461370 times.
✗ Branch 3 not taken.
2461370 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
8918
2/2
✓ Branch 0 taken 2461351 times.
✓ Branch 1 taken 19 times.
2461370 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
8919 72011241 return true;
8920
8921 2461351 return false;
8922 9285900 }
8923
8924 149973442 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8925 {
8926 149973442 bool ret = false, drunkstate = false, rawret = false;;
8927 149973442 bool* flag = &down_control_states[btn];
8928
2/7
✓ Branch 0 taken 140678205 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9295237 times.
149973442 switch(btn)
8929 {
8930 case btnF12:
8931 ret = zc_getkey(KEY_F12, ignoreDisable);
8932 rawret = zc_getrawkey(KEY_F12, ignoreDisable);
8933 eatEntirely = false;
8934 break;
8935 case btnF11:
8936 ret = zc_getkey(KEY_F11, ignoreDisable);
8937 rawret = zc_getrawkey(KEY_F11, ignoreDisable);
8938 eatEntirely = false;
8939 break;
8940 case btnF5:
8941 ret = zc_getkey(KEY_F5, ignoreDisable);
8942 rawret = zc_getrawkey(KEY_F5, ignoreDisable);
8943 eatEntirely = false;
8944 break;
8945 case btnQ:
8946 ret = zc_getkey(KEY_Q, ignoreDisable);
8947 rawret = zc_getrawkey(KEY_Q, ignoreDisable);
8948 eatEntirely = false;
8949 break;
8950 case btnI:
8951 ret = zc_getkey(KEY_I, ignoreDisable);
8952 rawret = zc_getrawkey(KEY_I, ignoreDisable);
8953 eatEntirely = false;
8954 break;
8955 case btnM:
8956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9295237 times.
9295237 if(FFCore.kb_typing_mode) return false;
8957 9295237 rawret = ret = zc_getrawkey(KEY_ESC, ignoreDisable);
8958 9295237 eatEntirely = false;
8959 9295237 break;
8960 default: //control_state[] index
8961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140678205 times.
140678205 if(FFCore.kb_typing_mode) return false;
8962
5/6
✓ Branch 0 taken 139878426 times.
✓ Branch 1 taken 799779 times.
✓ Branch 2 taken 2214788 times.
✓ Branch 3 taken 137663638 times.
✓ Branch 4 taken 2214788 times.
✗ Branch 5 not taken.
140678205 if(!ignoreDisable && get_qr(qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
8963
2/2
✓ Branch 0 taken 8035265 times.
✓ Branch 1 taken 132642940 times.
140678205 else if(btn<11) drunkstate = drunk_toggle_state[btn];
8964
4/4
✓ Branch 0 taken 126540836 times.
✓ Branch 1 taken 14137369 times.
✓ Branch 2 taken 3004 times.
✓ Branch 3 taken 14134365 times.
154815574 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
8965 140678205 rawret = raw_control_state[btn];
8966 140678205 }
8967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149973442 times.
149973442 assert(flag);
8968
2/2
✓ Branch 0 taken 95498690 times.
✓ Branch 1 taken 54474752 times.
149973442 if(press)
8969 {
8970
2/2
✓ Branch 0 taken 2888985 times.
✓ Branch 1 taken 51585767 times.
54474752 if(peek)
8971 2888985 ret = rButtonPeek(ret, *flag);
8972
2/2
✓ Branch 0 taken 50384650 times.
✓ Branch 1 taken 1201117 times.
51585767 else if(get_qr(qr_BROKEN_INPUT_DOWN_STATE)) ret = rButton(ret, *flag);
8973 1201117 else ret = rButton(ret, *flag, rawret);
8974 54474752 }
8975
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149973442 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149973442 if(eatEntirely && ret) control_state[btn] = false;
8976
3/4
✓ Branch 0 taken 112357731 times.
✓ Branch 1 taken 37615711 times.
✓ Branch 2 taken 112357731 times.
✗ Branch 3 not taken.
149973442 if(drunk && drunkstate) ret = !ret;
8977 149973442 return ret;
8978 149973442 }
8979
8980 7464182 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
8981 {
8982 7464182 byte ret = 0;
8983
2/2
✓ Branch 0 taken 5484862 times.
✓ Branch 1 taken 1979320 times.
7464182 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
8984
2/2
✓ Branch 0 taken 7333368 times.
✓ Branch 1 taken 130814 times.
7464182 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
8985
2/2
✓ Branch 0 taken 7333493 times.
✓ Branch 1 taken 130689 times.
7464182 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
8986
2/2
✓ Branch 0 taken 7333493 times.
✓ Branch 1 taken 130689 times.
7464182 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
8987
2/2
✓ Branch 0 taken 7333493 times.
✓ Branch 1 taken 130689 times.
7464182 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
8988
2/2
✓ Branch 0 taken 7333493 times.
✓ Branch 1 taken 130689 times.
7464182 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
8989
2/2
✓ Branch 0 taken 7333493 times.
✓ Branch 1 taken 130689 times.
7464182 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
8990
2/2
✓ Branch 0 taken 7333493 times.
✓ Branch 1 taken 130689 times.
7464182 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
8991 7464182 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
8992 }
8993
8994 1114 byte checkIntBtnVal(byte intbtn, byte vals)
8995 {
8996 1114 return intbtn&vals;
8997 }
8998
8999 1767275 bool Up()
9000 {
9001 1767275 return getInput(btnUp);
9002 }
9003 147059 bool Down()
9004 {
9005 147059 return getInput(btnDown);
9006 }
9007 257457 bool Left()
9008 {
9009 257457 return getInput(btnLeft);
9010 }
9011 286622 bool Right()
9012 {
9013 286622 return getInput(btnRight);
9014 }
9015 164908 bool cAbtn()
9016 {
9017 164908 return getInput(btnA);
9018 }
9019 1411891 bool cBbtn()
9020 {
9021 1411891 return getInput(btnB);
9022 }
9023 bool cSbtn()
9024 {
9025 return getInput(btnS);
9026 }
9027 68744 bool cLbtn()
9028 {
9029 68744 return getInput(btnL);
9030 }
9031 68744 bool cRbtn()
9032 {
9033 68744 return getInput(btnR);
9034 }
9035 bool cPbtn()
9036 {
9037 return getInput(btnP);
9038 }
9039 bool cEx1btn()
9040 {
9041 return getInput(btnEx1);
9042 }
9043 bool cEx2btn()
9044 {
9045 return getInput(btnEx2);
9046 }
9047 bool cEx3btn()
9048 {
9049 return getInput(btnEx3);
9050 }
9051 bool cEx4btn()
9052 {
9053 return getInput(btnEx4);
9054 }
9055 bool AxisUp()
9056 {
9057 return getInput(btnAxisUp);
9058 }
9059 bool AxisDown()
9060 {
9061 return getInput(btnAxisDown);
9062 }
9063 bool AxisLeft()
9064 {
9065 return getInput(btnAxisLeft);
9066 }
9067 bool AxisRight()
9068 {
9069 return getInput(btnAxisRight);
9070 }
9071
9072 bool cMbtn()
9073 {
9074 return getInput(btnM);
9075 }
9076 bool cF12()
9077 {
9078 return getInput(btnF12);
9079 }
9080 bool cF11()
9081 {
9082 return getInput(btnF11);
9083 }
9084 bool cF5()
9085 {
9086 return getInput(btnF5);
9087 }
9088 bool cQ()
9089 {
9090 return getInput(btnQ);
9091 }
9092 bool cI()
9093 {
9094 return getInput(btnI);
9095 }
9096
9097 130270 bool rUp()
9098 {
9099 130270 return getInput(btnUp, true);
9100 }
9101 130174 bool rDown()
9102 {
9103 130174 return getInput(btnDown, true);
9104 }
9105 130122 bool rLeft()
9106 {
9107 130122 return getInput(btnLeft, true);
9108 }
9109 129657 bool rRight()
9110 {
9111 129657 return getInput(btnRight, true);
9112 }
9113 1296 bool rAbtn()
9114 {
9115 1296 return getInput(btnA, true);
9116 }
9117 1296 bool rBbtn()
9118 {
9119 1296 return getInput(btnB, true);
9120 }
9121 7395997 bool rSbtn()
9122 {
9123 7395997 return getInput(btnS, true);
9124 }
9125 9285900 bool rMbtn()
9126 {
9127 9285900 return getInput(btnM, true);
9128 }
9129 129441 bool rLbtn()
9130 {
9131 129441 return getInput(btnL, true);
9132 }
9133 129436 bool rRbtn()
9134 {
9135 129436 return getInput(btnR, true);
9136 }
9137 7332461 bool rPbtn()
9138 {
9139 7332461 return getInput(btnP, true);
9140 }
9141 bool rEx1btn()
9142 {
9143 return getInput(btnEx1, true);
9144 }
9145 bool rEx2btn()
9146 {
9147 return getInput(btnEx2, true);
9148 }
9149 140087 bool rEx3btn()
9150 {
9151 140087 return getInput(btnEx3, true);
9152 }
9153 140087 bool rEx4btn()
9154 {
9155 140087 return getInput(btnEx4, true);
9156 }
9157 bool rAxisUp()
9158 {
9159 return getInput(btnAxisUp, true);
9160 }
9161 bool rAxisDown()
9162 {
9163 return getInput(btnAxisDown, true);
9164 }
9165 bool rAxisLeft()
9166 {
9167 return getInput(btnAxisLeft, true);
9168 }
9169 bool rAxisRight()
9170 {
9171 return getInput(btnAxisRight, true);
9172 }
9173
9174 bool rF11()
9175 {
9176 return getInput(btnF11, true);
9177 }
9178 bool rQ()
9179 {
9180 return getInput(btnQ, true);
9181 }
9182 bool rI()
9183 {
9184 return getInput(btnI, true);
9185 }
9186
9187 18224130 bool DrunkUp()
9188 {
9189 18224130 return getInput(btnUp, false, true);
9190 }
9191 16887361 bool DrunkDown()
9192 {
9193 16887361 return getInput(btnDown, false, true);
9194 }
9195 10287472 bool DrunkLeft()
9196 {
9197 10287472 return getInput(btnLeft, false, true);
9198 }
9199 8833428 bool DrunkRight()
9200 {
9201 8833428 return getInput(btnRight, false, true);
9202 }
9203 8034907 bool DrunkcAbtn()
9204 {
9205 8034907 return getInput(btnA, false, true);
9206 }
9207 8016355 bool DrunkcBbtn()
9208 {
9209 8016355 return getInput(btnB, false, true);
9210 }
9211 7263331 bool DrunkcEx1btn()
9212 {
9213 7263331 return getInput(btnEx1, false, true);
9214 }
9215 7263351 bool DrunkcEx2btn()
9216 {
9217 7263351 return getInput(btnEx2, false, true);
9218 }
9219 bool DrunkcSbtn()
9220 {
9221 return getInput(btnS, false, true);
9222 }
9223 bool DrunkcMbtn()
9224 {
9225 return getInput(btnM, false, true);
9226 }
9227 bool DrunkcLbtn()
9228 {
9229 return getInput(btnL, false, true);
9230 }
9231 bool DrunkcRbtn()
9232 {
9233 return getInput(btnR, false, true);
9234 }
9235 bool DrunkcPbtn()
9236 {
9237 return getInput(btnP, false, true);
9238 }
9239
9240 bool DrunkrUp()
9241 {
9242 return getInput(btnUp, true, true);
9243 }
9244 bool DrunkrDown()
9245 {
9246 return getInput(btnDown, true, true);
9247 }
9248 bool DrunkrLeft()
9249 {
9250 return getInput(btnLeft, true, true);
9251 }
9252 bool DrunkrRight()
9253 {
9254 return getInput(btnRight, true, true);
9255 }
9256 6081115 bool DrunkrAbtn()
9257 {
9258 6081115 return getInput(btnA, true, true);
9259 }
9260 6097947 bool DrunkrBbtn()
9261 {
9262 6097947 return getInput(btnB, true, true);
9263 }
9264 71669 bool DrunkrEx1btn()
9265 {
9266 71669 return getInput(btnEx1, true, true);
9267 }
9268 71662 bool DrunkrEx2btn()
9269 {
9270 71662 return getInput(btnEx2, true, true);
9271 }
9272 bool DrunkrEx3btn()
9273 {
9274 return getInput(btnEx3, true, true);
9275 }
9276 bool DrunkrEx4btn()
9277 {
9278 return getInput(btnEx4, true, true);
9279 }
9280 bool DrunkrSbtn()
9281 {
9282 return getInput(btnS, true, true);
9283 }
9284 bool DrunkrMbtn()
9285 {
9286 return getInput(btnM, true, true);
9287 }
9288 6688113 bool DrunkrLbtn()
9289 {
9290 6688113 return getInput(btnL, true, true);
9291 }
9292 6684638 bool DrunkrRbtn()
9293 {
9294 6684638 return getInput(btnR, true, true);
9295 }
9296 bool DrunkrPbtn()
9297 {
9298 return getInput(btnP, true, true);
9299 }
9300
9301 9337 void eat_buttons()
9302 {
9303 9337 getInput(btnA, true, false, true);
9304 9337 getInput(btnB, true, false, true);
9305 9337 getInput(btnS, true, false, true);
9306 9337 getInput(btnM, true, false, true);
9307 9337 getInput(btnL, true, false, true);
9308 9337 getInput(btnR, true, false, true);
9309 9337 getInput(btnP, true, false, true);
9310 9337 getInput(btnEx1, true, false, true);
9311 9337 getInput(btnEx2, true, false, true);
9312 9337 getInput(btnEx3, true, false, true);
9313 9337 getInput(btnEx4, true, false, true);
9314 9337 }
9315
9316 // Is true for the _first frame_ of a key press.
9317 // But! it is possible that a script manually sets the value of KeyPress,
9318 // in which case it will be restored to the "true" value based on `key_current_frame`
9319 // and `key_previous_frame` on the next frame.
9320 14 bool zc_readkey(int32_t k, bool ignoreDisable)
9321 {
9322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(ignoreDisable) return KeyPress[k];
9323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 switch(k)
9324 {
9325 case KEY_F7:
9326 case KEY_F8:
9327 case KEY_F9:
9328 return KeyPress[k];
9329
9330 default:
9331
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 return KeyPress[k] && !disabledKeys[k];
9332 }
9333 14 }
9334
9335 // Is true for _every frame_ a key is held down.
9336 // But! it is possible that a script manually sets the value of KeyInput,
9337 // in which case it will be restored to the "true" value based on `key_current_frame`
9338 // on the next frame.
9339 bool zc_getkey(int32_t k, bool ignoreDisable)
9340 {
9341 if(ignoreDisable) return KeyInput[k];
9342 switch(k)
9343 {
9344 case KEY_F7:
9345 case KEY_F8:
9346 case KEY_F9:
9347 return KeyInput[k];
9348
9349 default:
9350 return KeyInput[k] && !disabledKeys[k];
9351 }
9352 }
9353
9354 // Reads (and then clears) the current frame key state directly.
9355 // Scripts can also modify `key_current_frame`.
9356 303 bool zc_readrawkey(int32_t k, bool ignoreDisable)
9357 {
9358
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(zc_getrawkey(k, ignoreDisable))
9359 {
9360 2 _key[k]=key[k]=key_current_frame[k]=0;
9361 2 return true;
9362 }
9363 301 _key[k]=key[k]=key_current_frame[k]=0;
9364 301 return false;
9365 303 }
9366
9367 // Reads the current frame key state directly.
9368 // Scripts can also modify `key_current_frame`.
9369 63243703 bool zc_getrawkey(int32_t k, bool ignoreDisable)
9370 {
9371
2/2
✓ Branch 0 taken 53957775 times.
✓ Branch 1 taken 9285928 times.
63243703 if(ignoreDisable) return key_current_frame[k];
9372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285928 times.
9285928 switch(k)
9373 {
9374 case KEY_F7:
9375 case KEY_F8:
9376 case KEY_F9:
9377 return key_current_frame[k];
9378
9379 default:
9380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9285928 times.
9285928 return key_current_frame[k] && !disabledKeys[k];
9381 }
9382 63243703 }
9383
9384 // Only used for a handful of keys, like tilde and Function keys.
9385 // This state is never read within the game.
9386 // It exists so that all keyboard input still functions during replay,
9387 // without inadvertently doing things like toggling throttling if the player
9388 // presses ~
9389 9285900 bool zc_get_system_key(int32_t k)
9390 {
9391 9285900 return key_system[k];
9392 }
9393
9394 // True for the _first_ frame of a key press.
9395 83573100 bool zc_read_system_key(int32_t k)
9396 {
9397 83573100 return key_system_press[k];
9398 }
9399
9400 1179309300 bool is_system_key(int32_t k)
9401 {
9402
2/2
✓ Branch 0 taken 1095736200 times.
✓ Branch 1 taken 83573100 times.
1179309300 switch (k)
9403 {
9404 case KEY_BACKQUOTE:
9405 case KEY_CLOSEBRACE:
9406 case KEY_END:
9407 case KEY_HOME:
9408 case KEY_OPENBRACE:
9409 case KEY_PGDN:
9410 case KEY_PGUP:
9411 case KEY_TAB:
9412 case KEY_TILDE:
9413 83573100 return true;
9414 }
9415 1095736200 return is_Fkey(k);
9416 1179309300 }
9417
9418 9285900 void update_system_keys()
9419 {
9420
2/2
✓ Branch 0 taken 1179309300 times.
✓ Branch 1 taken 9285900 times.
1188595200 for (int32_t q = 0; q < 127; ++q)
9421 {
9422
2/2
✓ Branch 0 taken 195003900 times.
✓ Branch 1 taken 984305400 times.
1179309300 if (!is_system_key(q))
9423 984305400 continue;
9424
9425 195003900 key_system[q] = key[q];
9426
1/2
✓ Branch 0 taken 195003900 times.
✗ Branch 1 not taken.
195003900 key_system_press[q] = key_system[q] && !key_system_previous[q];
9427 195003900 key_system_previous[q] = key_system[q];
9428 195003900 }
9429 9285900 }
9430
9431 10390176 void update_keys()
9432 {
9433
2/2
✓ Branch 0 taken 1319552352 times.
✓ Branch 1 taken 10390176 times.
1329942528 for (int32_t q = 0; q < 127; ++q)
9434 {
9435 // When replaying, replay.cpp takes care of updating `key_current_frame`.
9436
1/2
✓ Branch 0 taken 1319552352 times.
✗ Branch 1 not taken.
1319552352 if (!replay_is_replaying())
9437 key_current_frame[q] = key[q];
9438
9439
2/2
✓ Branch 0 taken 1309764891 times.
✓ Branch 1 taken 9787461 times.
1319552352 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
9440 1319552352 KeyInput[q] = key_current_frame[q];
9441 1319552352 key_previous_frame[q] = key_current_frame[q];
9442 1319552352 }
9443 10390176 }
9444
9445 bool zc_disablekey(int32_t k, bool val)
9446 {
9447 switch(k)
9448 {
9449 case KEY_F7:
9450 case KEY_F8:
9451 case KEY_F9:
9452 return false;
9453
9454 default:
9455 disabledKeys[k] = val;
9456 return true;
9457 }
9458 }
9459
9460 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
9461 {
9462 timer=timer;
9463 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
9464 }
9465